One thing we have to keep in mind:
All atmospheres escape, always. Only the degree to which this happens is different on different planets.
I do appreciate your question a lot, as somehow people always forget about the existence of Venus when asking "what keeps an atmosphere in place?". As we will see, the classic story of "a magnetic field protects, that's all" is more of an urban myth.
Also all factors you have mentioned play a certain role. But let's pick them apart one-by-one, starting from the back in order to tell the story of escaping particles.
1. Distance
As you've correctly noted, distance plays a role indirectly by determining solar wind and irradiation at a given distance, so this factor is out as a direct cause.
After all, when modeling escape from planetary atmospheres one would rather take solar wind strength and UV-irradiation as free parameters rather than distance. This would make certain that one can compare planets around different stellar types, or stellar ages with each other. Thus, distance is usually not considered a free parameter in the literature.
2. Planetary Temperature
Temperature is not equal to temperature. The surface of a planet has a variation in temperature from equator to poles $\Delta T_{\rm EP}$.
Then again, the temperature varies with altitude above the planet. Similar to the sun, the temperature difference from surface to high up in the atmosphere/corona is $\Delta T_{SC}$ and one finds $\Delta T_{SC} \gg \Delta T_{\rm EP}$.
On Earth temperature variations go (very roughly) from $+40^{\circ}C$ to $-60^{\circ}C$, so $\Delta T_{\rm EP} \approx 100 K$, while the temperatures in the exosphere at 500km height go up to $T_{exo} = 1000K$.
Modern measurments and calculations for Mars and Venus give low exospheric temperatures of around $300K$, due to efficient cooling to space of $\rm CO_2$ (see this presentation by Coates et al. for Venus and a recent review by Lammer et al. (2008))
For the escape of particles into space, it is the lower boundary of the exopshere, the exobase, that determines escape rates. Particularly, it is the temperature and the density at the exobase that determines escape rates, as from here the fast tail of the Maxwell-Boltzmann distribution can directly head off into space. This is a particular escape process called Jeans-escape. Below the exobase particles that travel upwards at escape speeds will encounter on average more than one particle and thus be scattered without escape. This is btw. also the definition of where to find the exobase.
This is to illustrate that neither the surface temperature of planets, nor the variations thereof play any role for atmospheric escape. Very strictly this is not true, as the atmosphere of a star and possible young rocky planet can get hot enough to launch a hydrodynamic wind into space, greatly increasing escape rates. For the sun we call this phenomenon the Parker solar wind.
Now let's take a look how particles can escape from the exobase.
3. Particle mass
High up in the atmosphere, at around 100km height, there lies another atmospheric boundary, the homopause. Here mixing of particles due to large-scale motions of the air becomes so inefficient, that particles start forming layers according to their masses.
Heavier atomic and molecular species will thus, once they reach the exosphere $\sim$500km be there in much smaller numbers than, for example Hydrogen. Thus, hydrogen escape rates will always be higher than other species.
This is the 'classical' picture, which cannot explain some mysteries involving the noble gases. Noble gases are chemically inert, meaning they don't form molecules and once in the atmosphere, they should just hang around there for billions of years. Except for those who escape. This is why noble gases are giving important datapoints when constructing theories of what happened to Earth's atmosphere.
An important problem is that Xenon is missing, relative to its lighter counterpart Krypton and the other noble gases. This shouldn't be if the classical picture is correct. I recommend reading the introduction in the article of Zahnle et al. (2018) for a very detailed picture of this "missing Xenon problem".
In order to address this problem and this article, let me introduce another particle parameter:
4. Ionization energies
So particle mass only doesn't explain escape rates. the article of Zahnle et al. (2018) (and references therein, this is not a new idea) however proposes that if escape rates are mostly given by ions, then a different picture emerges, that could reconcile escape via mass fractionation and missing Xenon.
The general idea is that because the ionization energies differ as we move through the periodic system of elements, it is much easier to ionize Krypton and Xenon. A mass of ionized hydrogen, or protons will be pre-existent in the high atmosphere. Ion-ion collisions are much more efficient in coupling species together than ion-neutrals.
So if we now assume that instead of the neutral hydrogen, the protons mostly escape, they'd have dragged Krypton and Xenon ions along.
Except that under Earth atmospheric conditions the Krypton ions quickly recombine to neutral Krypton, while Xenon doesn't. So the Zahnle article concludes that the missing Xenon is a signpost of past, dominant ion escape.
So if ions are this important for atmospheric escape, as opposed to the neutral species, we probably have to think more about the magnetic field lines that they follow. Finally we get to discuss the planetary magnetic field.
5. Magnetic field and solar wind
Some magnetic field lines connect to the field in interplanetary space. Ions travelling along those will be inevitabely lost to space and picked up by the solar wind. The strength of this effect is dominated by the geometry of field lines intersecting with the solar wind, and can lead to net protection or net erosion of the atmosphere.
This, among with other effects like pick-up and sputtering have been summarized in a comparative article on Earth, Mars and Venus in Gunell et al. (2018). Their key finding is
While a planetary magnetic field protects the atmosphere
from sputtering and ion pickup, it enables polar cap and cusp escape,
which increases the escape rate. Furthermore, the induced
magnetospheres of the unmagnetised planets also provide protection
from sputtering and ion pickup in the same way as the
magnetospheres of the magnetised planets. Therefore, contrary
to what has been believed and reported in the press (Achenbach
2017), the presence of a strong planetary magnetic field does not
necessarily protect a planet from losing its atmosphere.
They find, that with all those complications of different escape processes and different ionized and neutral species, still for any single planet the ion escape rates can outcompete the neutral ones by a factor of $\sim 4$. Is this enough to explain the retention of the Venusian atmosphere and the escape of the Martian one? I think not. There is another factor that we've ignored so far.
6. Planetary mass
To close off this escape-story, I want to come back to the beginning of my answer, where I was happy that you've mentioned Venus. This is because Mars and Venus form a small set of a nearly identical case-study on atmospheric escape. Only two factors are different, while it is much harder to compare any other two planets in the solar system.
For the sake of comparing Mars and Venus to zeroth order, one could say that their atmospheres have identical composition, which is mostly $\rm CO_2$, as you have already stated. Both have no intrinsic magnetic field. Then, Venus has a hotter exosphere, stronger solar wind conditions, but still is somehow able to retain an atmosphere that has several thousand times more mass than the martian one.
If we now add to our perspective that a magnetic field doesn't play such a huge role for the retention of atmospheres, then the only remaining parameter that is different between Mars and Venus is the mass, which differs by a factor of about 10.
A factor of 10 is significant here, because if we go to planets now with 10 Earth-masses we already get into the regime of the Ice-giants Uranus and Neptune, which are able to hold on to their neutral hydrogen.
Understanding this is comparatively simple, as the totel escaping flux $\Phi_0$ is the integral of the Maxwell-Boltzmann-tail which goes very roughly as
$$ \Phi_0 \sim n(z_{\rm exo}) \cdot v_{\rm rms} \cdot \left( \frac{v_{\rm esc}^2}{v_{\rm rms}^2} + 1 \right) \cdot \exp(-\frac{v_{\rm esc}^2}{v_{\rm rms}^2}) $$
(source: Coates, or homework problems...)
where $n(z_{\rm exo})$ is the number density of a species at the height of the exosphere, $v_{\rm esc} = \sqrt{2GM/R}$ is the escape velocity of a planet with $M$ the mass and $R$ the radius and $v_{\rm rms} = \sqrt{2 kT_{\rm exo}/m}$ is the root-mean-square velocity of the MB-distribution at a given exospheric temperature $T_{\rm exo}$ for a given mean molecular mass $m$. So as there is an exponential factor involved, the Jeans-escape rate must go up quickly as planetary mass goes down.
So as ionic escape rates are a factor of a few times the neutrals, even if they dominate the scape, they're still bound to the exponential in the function.
More information can also be found in this, a bit older article by the same authors as the Zahnle paper, where they speculate also a little bit about escape from exoplanets, and the role of atmospheric chemistry for this effect.
Summary
The escape rate of ionic species can dominate over the escape rates of neutral species.
Ionic escape rates however don't react as strongly as one could think to the presence of a magnetic field. This leads to the interesting picture that the presence of a magnetic field is only a second order effect for determining escape rates.
The dominant parameter is then simply how deep the gravitational well of a planet is, that ions need to escape from. A escape rates go exponentially with planetary mass vs. molecular weight and available thermal energy at the exobase this is what determines escape rates most strongly.
Noble gases and their depletion can possibly resolve some mysteries of Earth's past, all the while telling us how much hydrogen has escaped from Earth.
As technology progresses, we might be able to address the same questions for Mars and Venus one day, but we're not there yet.
This was a long rant, please tell me if something is unclear.