When magnesium is burned, it reacts with oxygen in air not with the fire. The fire is the energy needed for the reaction to happen. Magnesium reacts with oxygen forming magnesium oxide. The light emitted from the reaction is because the reaction produced a lot of heat.