Hi Trinity, you really do ask the most fascinating questions. Well done. Let us explain.
Earth has more atmosphere than most of the other inner planets for two reasons: (1) gravity, and (2)
volcanism. Being the most massive of all of the inner planets, Earth can hold more atmosphere to its surface by its gravity alone. Furthermore, volcanoes continually spew out gasses into the Earth's atmosphere at a rate faster than they escape into space. Unlike Venus, however, which has an even thicker atmosphere, Earth also has oceans where gasses in the atmosphere are removed and crystallized into rocks. Earth is a living planet with a balanced dynamic equilibrium. Now, let us go back to Earth as it was a mere 3 billion years ago. No oxygen in the atmosphere, but lots of carbon dioxide, nitrogen and methane. Then, 2.45 billion years ago there is a very little oxygen in the atmosphere and tiny organisms known as cyanobacteria, or blue-green algae make their appearance. These microbes conduct photosynthesis: using sunshine, water and carbon dioxide to produce carbohydrates and, yes, oxygen. In fact, all the plants on Earth incorporate symbiotic cyanobacteria (known as chloroplasts) to do their photosynthesis for them to this day. It took another billion years, dubbed the "boring billion" by scientists for oxygen levels to rise high enough to enable the evolution of animals.Whether or not a planet retains an atmosphere over geologic time (billions of years) depends on the mass of the planet, the radius of the planet, the temperature of the atmosphere and the composition of the atmosphere. The atmospheres of the Earth-like planets (Mercury, Venus, Earth and Mars) originated by out gassing, probably associated with volcanism, of the interior of the planet. Mercury which is less than 10% the mass of the Earth has almost no atmosphere, because any gases that come out of its interior are moving faster than the escape velocity. The escape velocity is the minimum velocity an atom (or rocket) has to have at the surface so that it can escape the gravitational clutches of a planet. On Earth, any Hydrogen or Helium that comes from volcanoes can easily escape the Earth. Hence we have very little H and He in our atmosphere. On the other hand, any atom or molecule of more than the atomic mass 20 (i.e. Neon), will be retained by the Earth, because the mean speed of the atom is less than the escape velocity. The escape velocity from Earth is 11.2 km/s. Venus, which is about the same size and mass as Earth has a thick atmosphere made up of carbon dioxide. Mars which is 15% the mass of Earth has a thin atmosphere, because it can only retain the more massive molecules like CO2. The pressure on Mars' surface is 100 times less than on Earth. So to summarize, the principal factor as to whether a planet has a stable atmosphere is gravity. For massive planets, gravity overcomes the effects of thermal agitation and a molecule cannot escape the gravity field entirely. Small bodies like the MOON, have low gravity and the random thermal velocity that an atom has will send it zinging on its way into interplanetary space.