fang1 is from the pattern which means 'a plough'. Its meaning of 'square' may have been from the observation that inserting the plough into the soil at a right angle is the most efficient way of tilling soil. Other meanings of fang1 are 'direction', 'locality', 'method' and 'recipe'.
li4fang1 means 'cubic' and literally translates as 'stand'-'square'.
li4 means 'stand' and is a graphical representation of a man with two legs firmly planted on the ground.
di4fang1 means 'place' and literally translates as 'ground'-'square'.
is made up of the two components.
tu3 which means 'soil' and
ye3 which in ancient times denoted the 'snake'. Together
the meaning becomes 'soil where the snakes are'.