Like any other form of matter gas molecules feel the gravitational pull of the planet they surround, so they're attracted to the planet by gravity. At any temperature above absolute zero the atoms/molecules in a gas have a velocity distribution known as the Maxwell-Boltzmann distribution. As long as their velocities remain well below the escape velocity of the planet the atmosphere will be bound to it.
Although this gives the basic idea it's an oversimplification for several reasons. For example the escape velocity decreases as you move up through the atmosphere, however the temperature changes as well so the average gas atom/molecule velocity also changes with height. Also even if the average is well below the escape velocity a small fraction of molecules will have high enough velocities to escape. However even then only molecules near the top of the atmosphere are likely to escape as the mean free path near the ground is too short for even an energetic molecule to escape. Finally radiation from the Sun is an important factor in removing gas molecules from planets. On Earth the magnetic field keeps most of the radiation out, but on Mars gas loss due to solar radiation is important.
For more info you might want to have a look at the Wikipedia article on atmosphere loss.
I'm not sure what your second question is asking as it doesn't seem relevant to atmosphere loss. If you're asking why planets generally have a non-zero tilt this should be posted as a separate question. In brief, for most planets the tilt is chaotic and varies contnuously, and the planet may even flip over completely. Earth's tilt is stabilised by the moon and varies only slightly with time.
Re the revised question: At any given temperature the average velocity of lighter gas molecules is greater than heavier gas molecules, so it's the ligher gas molecules that escape most easily. For example the Earth loses a few kg of hydrogen per second but almost no oxygen or nitrogen.
However if the rate of loss of a light gas is very fast it can carry molecules of heavier gases along as well by colliding with them and transferring momentum to the heavier molecules. This is known as hydrodynamic escape. Note that this only happens when there is a rapid loss rate of the lighter gas, so it isn't happening to any significant extent on any of the planets in the solar system.