The solar system formed dust and many gases in a nebula. The center of the nebula eventually became the sun. The flat rings of outside the nebula became the orbit paths, and that is where the planets stay and rotate around the sun. After that dust particles and gases that were found were all combined up to create planets and moons.