Secondary atmosphere

A secondary atmosphere is an atmosphere of a planet that did not form by accretion during the formation of the planet's star. A secondary atmosphere instead forms from internal volcanic activity, or by accumulation of material from comet impacts. It is characteristic of terrestrial planets, which includes the other terrestrial planets in the Solar System: Mercury, Venus, and Mars. Secondary atmospheres are relatively thin compared to primary atmospheres like Jupiter's. Further processing of a secondary atmosphere, for example by the processes of biological life, can produce a tertiary atmosphere, such as that of Earth.

Starting point
During planet formation, gas and dust from the Sun's protoplanetary disc accrete onto all forming planets. Depending on the final size of the planet, it may or may not have enough gravity to retain this first, primary atmosphere or the star's solar winds strip the atmosphere off of the planet. The giant planets, such as Jupiter and Saturn, became large enough where they were able to hold onto their primary atmosphere that they gained during formation while terrestrial planets, such as Venus and Earth, do not have enough gravity to hold onto the original atmosphere. By being made of rock, they are able to go through geologic processes that will produce gas into the atmosphere.

Post-primary atmosphere
If the planet is too small, then its gravity isn't strong enough to hold onto all of the gas it gained during formation. This causes the primary atmosphere, which is mostly made of hydrogen (H2) from the nebula the solar system formed in, to run away and leave the planet entirely. Hydrogen, being the lightest element, will naturally escape the atmosphere due to it being the most buoyant. If a planet is to gain a new atmosphere, it must create one with materials found within the planet itself.

Volcanism is an example of a geologic process that will pump out volcanic gasses, such as carbon dioxide (CO2) and sulfur dioxide (SO2), that come out from a variety of sources. During the hot protoplanet phase, the molten planet or moon will cool off which will cause the surface to solidify. Material still want to outgas which causes openings in the crust which will spew out gas that is often trapped in the cavities of rocks which include the asteroids, meteors, and comets that bombard the surface of a planet during, and after, its formation. The molten magma or lava is able to retain gasses that are dissolved or bonded with the magma or lava itself and release at the opening of the volcano where the pressure becomes low enough to sublimate.

Water (H2O) is a very common molecule throughout the universe, so asteroids and comets during the solar system's formation were likely what brought water around the solar system. When the water is first delivered, it mixes in with the surrounding lava and stays trapped until it cools off enough. The volcanoes, along with the other gasses mentioned above, will also spew out water vapor that was trapped in the magma. In the case of Earth, its earliest secondary atmosphere was almost entirely made up of water vapor and carbon dioxide.

Planetary conditions
The result of a planet gaining an atmosphere once the first is lost is heavily dependent on the planet's individual conditions as well as the conditions of its placement in the solar system. Different types of stars have varying amounts of solar wind and harmful radiation. These are the components that tend to strip a planet of its atmosphere in the first place. For example, Mercury does not have an atmosphere because it is so close to the sun that the solar winds have stripped it from the planet. Earth has an atmosphere largely because of the magnetic field which deflects most of the harmful radiation and solar winds away from the surface. Not only does Earth have an atmosphere due to outgassing but its favorable conditions has given rise to life that produces gas as a byproduct such as photosynthesis creating oxygen, which is the characteristic needed to create a tertiary atmosphere. Venus, on the other hand, does not have a magnetic field which means it is bombarded by solar wind and radiation, but the planet's volcanic activity continues to pump out more carbon dioxide into its atmosphere.