For Earth, the answer is simple: life. In the absence of life, a nitrogen-oxygen atmosphere is thermodynamically unstable. Our best current understanding is that the atmosphere of the early Earth, before life developed, was mostly methane and ammonia, which are commonly observed in the atmospheres of the outer planets and their satellites. Once life developed, the methane and ammonia were gradually chemically converted by life to water and nitrogen.
For the others you mention, oxygen is not present, and the nitrogen is combined with methane (plus traces of carbon monoxide or carbon dioxide). I have not seen detailed thermodynamic calculations, but if there are very few oxygen atoms present, nitrogen plus methane should be thermodynamically stable. The unique feature of Earth as compared with these others would be the presence of a sufficient quantity of oxygen atoms to oxidize the nitrogen to ammonia in the early atmosphere before life developed.
For Mars, it is close enough to the Sun and small enough to make its temperature too high for it to retain significant amounts of nitrogen or methane (it has traces of both, IIRC), so CO2, which is significantly heavier, is the only significant component left.
For Venus, a significant amount of nitrogen gas is present (about four times as much as in Earth's atmosphere--Venus is significantly larger than Mars so its gravity can keep the nitrogen from escaping), but this is masked by the enormous amount of CO2 present (about 95 atmospheres worth), which AFAIK is believed to be due to all of the calcium carbonate in the surface rocks having been driven into the atmosphere due to a runaway greenhouse effect raising the temperature.
For example, it's the outer planets that are gas giants. Venus composition doesn't seem too different from Earth but it's much closer to Sol, so it's more exposed with much more energy absorbed etc.
That's the simplest assumption.
Something interesting I didn't know is that apparently Venus has almost no plain oxygen.
Mars, on the other hand, doesn't have much nitrogen. Perhaps that's attributable to the relative lightness of N2, which would be more prone to float off into space than the somewhat heavier CO2.
https://en.wikipedia.org/wiki/Stromatolite#cite_ref-PiP_15-1
A lot of carbon was also captured during the aptly-named Carboniferous Period 360-300 million years ago. Woody plants had just evolved, but microbes that could break them down had not. Thus, coal. An earlier drop in sea levels also caused carbonate (as in limestone, dolomite, and iron ores) to precipitate out. The combination of these effects pushed oxygen levels about 50% above present, allowing very large animals to evolve.
Does this mean we’ll never have coal again?
Interestingly, this has happened once before. There's a "coal gap" from about 250-230 million years ago during which little-to-no coal was formed in most places. I'm not sure if anyone is sure why; this is right at the time of the P-Tr extinction, so a lot was happening. One theory is that the ligninaceous plants went extinct or other conditions were much less conductive to coal formation.
(FYI: Not a paleontologist or anything like--just a scientist who liked dinos as a kid and remembered some keywords!)
The resulting glaciation extended across the entire planet, was kilometers deep, and lasted 100s of millions of years.
All because blue-green algae.
I assume it's something to do with: https://en.wikipedia.org/wiki/Limestone
For CO2, the pattern is temperature. Titan, Triton, Pluto are well below CO2's freezing point so it stays on the surface as ice instead of atmosphere. At these temperatures, nitrogen is the heaviest abundant molecule that remains gaseous, followed by methane. If you're warm enough for gaseous CO2, you have it. The only exception is Earth and that's because plant life absorbed it and emitted O2 instead.
For nitrogen, methane, argon, the pattern is mass. Only Venus and Earth have enough mass to hold on to those, compared to heavier CO2. Venus and Earth have similar quantities of those. Venus's excess of CO2 comes from temperature high enough to evaporate carbon and oxygen from rock compounds.
Mars and Venus are both in the inner Solar System, and both have very weak magnetic fields.
I mean, aside from specifics about each, what's the pattern that you would apply to an arbitrary planet?