The Origin of Atmospheric Gases:

Major Gases:
Nitrogen
Nitrogen in the atmosphere originated inside the early initial formation of the Earth.  It escaped into the atmosphere primarily through volcanic eruptions.  It takes part in various biological reactions, but other than that, is largely chemically inert (unreactive) except when heated to high temperatures (several hundred degrees at least).  Because of that, it has accumulated to be the largest single component - about 78% of the atmosphere.

Oxygen
The origin of oxygen in the atmosphere is primarily due to photosynthesis.  A very secondary source (and primary source before the evolution of photosynthetic organisms) is lightning strikes, which break water molecules at the surface and in the atmosphere into its component hydrogen and oxygen.

Early in the Earth's history, there was almost no oxygen gas in the atmosphere.  When photosynthesis evolved more than 3 billion years ago, any oxygen that was released, immediately combined with dissolved ionic iron in the ocean, to oxidize that iron (basically, forming rust).  This iron oxide accumulated in vast layers around the world, known as "Banded Iron Formations", or "BIF"s.  These range in age from more than 3 billion years old up to about 1.8 billion years old, and are a major source of iron ore world wide (You can see a beautiful example of a BIF in our museum in the lobby of the X building on the SFC NW campus).  And oxygen was unable to increase in our atmosphere
until all that oceanic dissolved iron was oxidized.  Thus that also was a key control on the development of multicellular life.

Oxygen is used up via respiration from animals and bacterial decomposition, weathering of rocks at the surface, and combustion mostly in forest fires.

Why does oxygen have the percentage it does in our atmosphere?  Imagine that it was much higher than it is. The rate of combustion due to forest fires would increase, lowering the percent of oxygen.  Suppose that it was much lower than it is today.  The rate
of combustion due to forest fires would decrease, and if O2 were low enough, even respiration would decrease.  This would cause the amount of oxygen to rise again.  So the amount of oxygen is self-regulating, and it is unlikely that, since the accumulation of oxygen in the atmosphere after the formation of BIFs, the percentage of oxygen has been much more than a few percent higher or lower than it is today, about 21%.

Argon

Argon was present within the earth upon its original formation, and is also formed by radioactive decay of 40K into 40Ar.  Argon is a fairly heavy Noble Gas and is chemically unreactive, so when it escapes from the earth through weathering or volcanism, it simply stays in the Earth's Atmosphere.  Most of the Ar in our atmosphere today is 40Ar, suggesting that most of it was formed by radioactive decay.

Interestingly,
Argon is also a significant gas in the atmospheres of Mars and Venus, and is mostly 40Ar, showing us that Venus, Earth, and Mars share a similar geochemistry.

Carbon Dioxide
Carbon dioxide is a common gas in the universe, and likely was "primordial" (present from the original formation of the Earth).  It has gradually escaped from the Earth's interior to be a major constituent of our early atmosphere.

There are many sources and sinks for CO2, though.  It continues to be added to the atmosphere from the Earth's interior through volcanism.  It is added also through respiration from animals and from bacterial decomposition of organic matter.  Certain kinds of weathering of rocks and minerals add it to the atmosphere.  And combustion of organic materials through wild fires and human activities (power plants, heating, automobiles) add it to the atmosphere.  Underground burning of abandoned coal mines also add significant amounts to the atmosphere.

Carbon dioxide is removed from the atmosphere by photosynthesis to form the "biosphere", and by absorption into the oceans so much that there is about 60x more
CO2 in the ocean than in the atmosphere.  The formation of fossil fuels has sequestered hundreds of times more CO2 than is presently in our atmosphere.  In the ocean, it is removed also by photosynthesis and even more importantly by shelled organisms (molluscs, arthropods, corals, foraminifera, echinoderms, and many others).  So much  has been removed by shelled organisms during the history of our planet that there is around 100,000x more CO2 in limestones worldwide than in the atmosphere.  Without those limestones, we would have FAR more CO2 in our atmosphere.  (This is why the atmosphere of Venus has around 100,000x more CO2 than our atmosphere.  No life ever evolved there.)  Certain weathering processes also remove as well as add CO2 from the atmosphere.

Minor (Trace) Gases:
Neon
Neon was present within the earth upon its original formation.  Neon is a Noble Gas and is chemically unreactive, so when it escapes from the earth through weathering or volcanism, it simply stays in the Earth's Atmosphere.

Helium
Helium was present within the earth upon its original formation.  Helium is also formed from Alpha Particle decay of many radioactive isotopes withing the Earth.  Helium is a Noble Gas and is chemically unreactive, so it escapes from the earth through weathering or volcanism, and winds up in the Earth's Atmosphere.

Helium is such a light atom that it continually escapes from the Earth's atmosphere into space.  It is, however, also continually replenished via production from Alpha Particle decay within the Earth, so we have a very small but likely constant amount of He in the atmosphere.

Methane
Methane (CH4) gas is primarily produced by anaerobic (without oxygen) respiration by bacteria, a process called "methanogenesis".  Its primary sources natural sources are termites and oxygen-poor organic-rich soils (wetlands) and marine sediments, although the soil and sediment methane can be trapped for long periods.  Anthropogenic (production related to humans)
CH4 is produced in rice paddy sediments and livestock, especially ruminants, which have bacteria in their gut to help break down cellulose.  Humans themselves produce about 1 liter (1 quart) of CH4 per day in our guts.  Unfortunately, methane is also released accidentally and sometimes deliberately during mining and petroleum drilling operations (although the deliberate release is now generally illegal).

Natural gas formed in soils and marine sediments may be trapped by chemical reactions as solid materials known as clathrates (methane hydrates).  These are solids composed of water molecules that trap
CH4 molecules.  They are stable only at low temperatures (in permafrost) and high pressures (in deep sea sediments), and there is concern that during periods of planetary warming, large amounts can be released.  This is thought to be the reason for the Paleocene-Eocene Thermal Maximum, a time of catastrophic short-term temperature increases about 55 million years ago, which led to world-wide extinctions.

Methane is the major component of Natural Gas, and is produced primarily by heating of organic material under pressure.  Bacteria may also play a part as well.

Methane is removed from the atmosphere by a variety of processes, most important of which is oxidation in the Troposphere.

Krypton
Krypton
was present withing the earth upon its original formation.  Krypton is a Noble Gas and is chemically unreactive, so when it escapes from the earth through weathering or volcanism, it simply stays in the Earth's Atmosphere.

Hydrogen
Hydrogen is highly reactive and any H
2 gas that is present in the atmosphere quickly combines with O2 to form water vapor.  It is formed primarily through lightning strikes that break water apart, so there is always a very small amount in the atmosphere, although any given H2 molecule is not present very long.
 
Water
Water is a primordial component of the atmosphere, and water vapor is added to the atmosphere whenever a volcano erupts.  There is evidence that there is still as much water trapped in the Earth's crust and mantle as is present on the surface of the Earth.  Water is broken into its component hydrogen and oxygen whenever lightning bolts strike.  The hydrogen can escape to space, so we can look VERY long into the future to a time when the Earth may lose its water.

Pollutant Gases:
Carbon Monoxide
Carbon monoxide [CO] (not to be confused with carbon dioxide [CO2] is produced by incomplete combustion of organic materials, principally hydrocarbons.
Why doesn't
CO2 form instead of CO?  Either because there isn't enough time during the burning process for oxygen to completely react with the carbon in the hydrocarbon molecules, or because there simply is not enough oxygen present during the burning process. 
This occurs in power plants, kerosene heaters, and especially internal combustion engines. 
This is why, among other things, it is important to keep your car engine tuned up, and why you should never use a kerosene heater indoors.  Combustion without enough O2 produces CO instead of CO2.  As such, it is higher along roadways and downwind of major coal-fired power plants.
Highly toxic and very dangerous.

Ammonia
The volatilization of nitrogen fertilizers is believed to be the most important anthropogenic source. However, atmospheric ammonia from urban areas has been attributed to vehicles (heating in internal combustion engines).

Nitrous Oxides

There are a variety of oxides of nitrogen in the atmosphere, including N2O (Nitrous Oxide, AKA Laughing Gas) and NO2.  Most of the nitrous oxides emitted into the atmosphere, from natural and anthropogenic sources, is produced by microorganisms such as bacteria and fungi in soils and oceans.  Soils under natural vegetation are an important source of nitrous oxide, accounting for 60% of all naturally produced emissions. Other natural sources include the oceans (35%) and atmospheric chemical reactions (5%).  A 2019 study showed that emissions from thawing permafrost are 12 times higher than previously assumed. (from Wiki).
Produced artificially in internal combustion engines and power plants by reaction of N2 at high temperatures with oxygen gas.

Sulfur Dioxide
Sulfur dioxide (SO2) is emitted naturally by volcanoes.  However,
about 99% of the sulfur dioxide in air comes from human sources. The main source of sulfur dioxide in the air is industrial activity that processes materials that contain sulfur, e.g. the generation of electricity from coal, oil or gas that contains sulfur.  In addition, industrial activities that burn fossil fuels containing sulfur can be important sources of sulfur dioxide.  Some mineral ores also contain sulfur, and sulfur dioxide is released when they are processed.

Sulfur dioxide is also present in motor vehicle emissions, as the result of fuel combustion. In the past, motor vehicle exhaust was an important, but not the main, source of sulfur dioxide in air. However, this is no longer the case.

ChloroFluoroCarbons
ChloroFluoroCarbons [CFCs] are a completely artificial class of chemical compounds used as refrigerants and propellants.  In that role, they are very effective. They are non-toxic, stable, and have good thermodynamic properties.  They are not currently being manufactured.  They break down slowly due to chemical reactions in the atmosphere.