Flares burn with a bright light when activated. Burning is a combustion reaction. Combustion reactions occur when a material reacts with oxygen, yielding a modified chemical product and energy (in this case, in the form of heat and light). Combustion reactions are therefore by definition exothermic reactions.
In the case of a magnesium flare, magnesium reacts with oxygen to produce heat and magnesium oxide. See the following balanced equation:
2Mg(s) + O(g) -> 2MgO(s) + energy
In the above equation, subscripts are noted by brackets , (s) indicates solid matter and (g) indicates gaseous matter. Thus we can see that magnesium flares react with the oxygen present in air.
If you would like to see more details of how magnesium reacts, please see the attached link below.