So we want to know how did the planets form in the Solar system. So the current most accepted explanation is accretion. First the Sun formed, and what has left was a disk made out of gas and dust which later formed the planets trough attractive gravitational force.