Planets form from particles in a disk of gas and dust, colliding and sticking together as they orbit the star. The planets nearest to the star tend to be rockier because the star's wind blows away their gases and because they are made of heavier materials attracted by the star's gravity.