It's because the Moon lacks an atmosphere.
CO (and then CO2) form at high temps, so elemental carbon doesn't have much chance to condensate to a "rock" form in regards to non-stellar celestial bodies. These float off into space, no atmosphere to contain them.
At the temperatures/pressure of the moon, Nitrogen rapidly boils off and floats away as well.
Not sure about Phosphorus and Sulfur, but I'm sure they can be either directly or indirectly related back to the moon's lack of an atmosphere as well.