I always assumed it was the low gravity that caused the loss of atmosphere. I remember it being proposed that orbiting mirrors might sublimate the CO2 icecaps, releasing CO2 and heating things up. I think it would need to be reconstituted though.
Of course it's gravity- how can magnetism act on gases? Other factors are needed because gravity is constant; rotational speed, greenhouse effect, solar intensity, etc
AFAIK, and as b_b suggests, the magnetic field can protect the atmosphere from the solar wind. According to Wikipedia: Not something I knew about.The solar wind affects the other incoming cosmic rays interacting with the atmosphere of planets. Moreover, planets with a weak or non-existent magnetosphere are subject to atmospheric stripping by the solar wind.