Planets form from the same cloud of gas and dust that the star they orbit formed from. They are both built from the same material. However, stars are mostly hydrogen and helium, and rocky planets like Earth are entirely made of heavier elements like oxygen, silicon, and magnesium. If the cloud the star and planets are forming from is richer in these heavier elements, there is more material to make planets. Indeed, astronomers find that planets are more common around stars that contain more of the planet-building elements.