It seems obvious why mercury has no atmosphere, given its proximity to the sun--but yet Venus is also fairly close, and has an extremely dense atmosphere. Titan is a large moon with an atmosphere thicker than Earth's, and then Triton, a more distant large moon, has only a tenuous Nitrogen atmosphere. Why aren't more rocky bodies able to maintain an atmosphere? What factors affect whether a planet or moon is able to hold on to its atmosphere? What factors determine whether a planet or moon develops an atmosphere to begin with?
There are a lot of factors that go into whether or not a planet has an atmosphere.
First, the mass and size of the planet. Really what it comes down to is the escape velocity. The higher the escape velocity (ve), the easier it is for a planet (or moon) to retain any atmosphere it gets as the gases that make up the atmosphere have to be moving faster to escape. Now ve is proportional to the square root of mass divided by radius and mass is proportional to density times radius cubed. Since the density of the rocky bodies in the Solar System are basically the same (and the icey bodies only differ by a factor of 2-3) density is roughly constant and that means that ve is basically just proportional to the radius of the object. So larger objects have a higher escape velocity and are more likely to retain an atmosphere.
Next is temperature which is just a measure of the average energy of the particles. So the gas molecules that make up the atmopherers of hot planets have a higher average energy than the molecules in a planet that is cooler. Since the average energy translates into the speed of the gas particles, gasses on warmer planets are more likely to be close to or over the escape velocity of the planet and as such can fly off into space. So cooler planets have a higher chance of holding on to their atmospheres since the particles are moving slower.
Next we have atmopheric composition. At a given temperature more massive particles are going to be moving slower. Thus if you have Hydrogen gas, with a molecular weight of 2, compared to oxygen gas, molecular weight 32, the Hydrogen will be moving on average 16 times faster and is much more likely to escape. CO2, with a molecular weight of 44, will be moving even slower still. Thus for a given planet with a fixed mass and temperature, the lighter gasses will escape first.
Finally we have availability of materials. If there are no gasses there to start with and no way to acquire them, it doesn't matter how massive or how cold the planet is, there is nothing there to hold on to.
It has largely to do with the density of the planet. This is not the overall Mass of the planet but the density since that is the main factor which determines the gravity per cubic centimetre. After this you might consider the fact that planets with lower gravity would not be able to hold a significant atmosphere like Mars.
If a planet still has a hot core (like Earth), it will release gases needed for an atmosphere to form. Also, the planet should have enough gravity to hold the gases close to the planet.