Obviously the hydrogen and helium were gaseous and too light for Earth's gravitational field (other than hydrogen in molecules like H2O).
Oxygen is the second most abundant element on Earth. Even though it can exist in the gaseous O2 form, I assume this is because of how it combines with so many heavier elements and is trapped in the ground.
Carbon, neon and nitrogen however have a much lesser abundance in the Earth than cosmic abundances. Can we assume that this is proof that there was a solar event that blew most of the gases away during early planetary formation. (Carbon because of its gaseous form in CO and CO2)?
Oxygen, unlike Carbon or Nitrogen, bonds readily with Silicon, Magnesium, Iron and other heavy elemets, which is why Oxygen is very abundant in rocky planet formation. It's one of the elements abundant in space-dust, unlike CO2, H20, CH4, NH3, which can form, in colder regions, ice or snow like formations as they begin to clump together, but only in cold regions of space.
The sun didn't precisely have an "event", though young stars after formation can be much more violent. The initial heat of formation can be very bright and very hot, and young stars are usually rotating very fast and prone to much bigger solar storms and very large mass ejections. Pretty much all stars go through a violent youth. It's not a unique event to our solar-system.
Common elements in space, such as CO2, H20, CH4 and NH3 are gaseous at Earth's distance from the sun and as a result, are unlikely to stick to anything in the Earth's formation region. This is true for all 4 inner planets and likely all rocky worlds. Rocky planets likely can only form close to their star, just as gas giants, ice giants or other icy abundant bodies like comets and low-density moons, can only form further out.
Gases like the 4 above can begin to be retained around a planet after it reaches a sufficiently large mass with low enough surface temperature to retain those gases by gravity.
The boundaries where CO2, H20, CH4, NH3 and other gases can be found in the protoplanetary disk is called the frost line. Different gases have different frost lines depending on their freezing point.
It's thought that much of Earth's water, CO2, CH4 and NH3 came to the Earth by comet after the planet formed. There's still some uncertainty on the percentages, as some of those elements could have been trapped during formation.
Just to add, hydrogen and helium are obviously abundant, but will only begin to accrue around a planet of a certain mass. In our solar-system, only Jupiter and Saturn are massive enough to accrue hydrogen and helium. That's why Uranus and Neptune are relatively low on hydrogen and helium compared to the universal abundance.
Argon is in Earth's atmosphere because it forms from gradual radioactive decay of Potassium-40. Earth's Helium is also present as a result of radioactive decay.