To state the obvious, an astronomical body has to produce or acquire an atmosphere in order to have one. Thus the composition of a atmosphere is likely to be the product of the average atmospheric acquisition rate per time unit multiplied by the number of time units between starting to acquire an atmosphere and stopping acquiring an atmosphere.
Minus the average atmospheric loss rate per time unit multiplied by the number of time units between starting to lose an atmosphere and stopping losing an atmosphere. At any one time an astronomical body may be both gaining and losing atmosphere, gaining but not losing atmosphere, losing atmosphere and not gaining any, or neither gaining nor losing any atmosphere.
And of course the rates of atmospheric gain and loss can vary enormously.
One way for a planet to lose atmosphere is to have fast moving molecules, atoms, & ions escape into interplanetary space. Molecules, atoms, and ions escape from the outer layers of an atmosphere. I once read that it was calculated that if the escape velocity of the astronomical body was X times the average speed of the particles in the escape layer the astronomical body would retain atmosphere for billions of years without much escape. I don't remember exactly the value of X, but I think it was either 5 or 6.
I believe the velocity of particles in the escape layer of an atmosphere depends on their temperature, which is the result of direct solar radiation upon them plus any heat rising up from the astronomical body. Thus some astronomical bodies far from the Sun, like Titan and Triton, are able to retain more atmosphere than they would be able to if at Earth's distance from the Sun.
Astronomical bodies also lose atmospheric particles into space due to charged particles in the solar or stellar wind emitted by the star striking the atmosphere. Astronomical bodies with strong enough magnetic fields are protected from that process by deflecting or trapping the charged particles.
Atmospheres can also be lost by turning liquid or solid. On Earth, for example, carbon dioxide, a greenhouse gas that keeps Earth warm enough for life, is trapped into minerals and lost from the atmosphere. Over ages of time plate tectonics gradually pushes some plates of the crust beneath other plates and down into the magma layer. Eventually some of that carbon dioxide enriched magma reaches the surface and carbon dioxide is released back into the atmosphere, maintaining a rough equilibrium. Planets without plate tectonics will not have that carbon dioxide cycle.
On Earth, most plants and animals release carbon dioxide into the atmosphere, while plants also convert carbon dioxide and sunlight into biochemicals and oxygen, thus producing Earth's free oxygen in the atmosphere.
Thus it is relatively simple to calculate whether a specific astronomical body would retain a specified atmosphere for billions of years, and much lss easy to calculate whether it would ever acquire that specific type of atmosphere given the initial conditions of planetary formation.