I've always assumed that the large numbers of gemstones found in Equestria are due to magic flowing in the earth there. Where it becomes concentrated, the base rock and earth transmutes into gemstone.



Self-contained biomes powered by magic are probably created the same way. Equestria should be full of caves like this one.