Exploratour - Evolution of the Solar System
This drawing shows how forming planets drew molecules to themselves for an atmosphere.
Click on image for full size
Image from: The New Solar System
Click on image for full size
Image from: The New Solar System
As shown in this picture, while they were forming in the flattened disc of the solar nebula, the core of the planets-to-be drew material to themselves from the cloud of gas and dust around them. The bigger planets-to-be were able to draw even more material unto themselves because of gravity.
This is page 8 of 60