According to this theory, the Sun and all the planets of our Solar System began as a giant cloud of molecular gas and dust.
Something caused the cloud to collapse, maybe a shooting star maybe shock waves from a supernova, ect...
From this collapse, pockets of dust and gas began to collect into denser regions. As the denser regions pulled in more and more matter, conservation of momentum caused it to begin rotating, while increasing pressure caused it to heat up
Most of the material ended up in a ball at the center while the rest of the matter flattened out into disk that circled around it.
Planets formed by accretion from this disc, in which dust and gas gravitated together and coalesced to form ever larger bodies.