(a) There is small escape velocity in case of moon, as there is small gravitational force. The rms speed of the air molecules is smaller than the escape velocity on moon, but a significant number of molecules had greater speed than the escape velocity, and hence they escaped. Now, the other molecules arranged the speed distribution for equilibrium temperature. Again a significant number of molecules escaped, because their speed exceeded the escape velocity. So, over a long time, the moon lost most of its atmosphere.
(b) When the potential energy of molecules increases, the molecules move higher, and thus kinetic energy reduces. This results in lowering of temperature. With altitude, the gas expands and hence cooling occurs.