Sublimation only happens if the ice is near its freezing point so that there is still considerable internal energy inside the ice to cause molecules of the ice to 'boil off' from its surface. For comets and ices on the lunar surface in shadow, the temperature is well below the freezing point of the ice, so there is little internal heat available to boil off the molecules. The result is that ice molecules remain where they are, and in the case of the moon, any new ice molecules in the atmosphere get stuck to this core of ice which then acts like a 'cold trap' pumping ice molecules out of the atmosphere. This same principle is used in vacuum pumps in earth labs.