why the layer on magnesium ribbon is of magnesium carbonate not of magnesium oxide?
The layer that is formed on the surface of magnesium is that of magnesium oxide. Magnesium is an extremely reactive metal. When stored, it reacts with oxygen to form a layer of magnesium oxide on its surface. This layer of magnesium oxide is quite stable and prevents further reaction of magnesium with oxygen. The magnesium ribbon is therefore cleaned by sand paper for removing this layer so that the underlying metal can be exposed to air.
Mg + O2 ------> 2MgO