How can metals like magnesium and sodium burn underwater? Please answer with as much detail as possible. I can't find the answer anywhere else and I need it for an essay.

Any websites I have found have conflicting answers.

One said that they don't actually burn underwater, rather than separate hydrogen from oxygen and burn at the surface. Another actually said that they do burn underwater because they take the oxygen source from the water. I do not have a specific definition for "burn" (the question itself is my assignment- write an essay answering that question!), so I know about as much as you do concerning the wording of the assignment.

I do know that alkali and alkaline earth metals are generally very reactive with water, and usually result in exothermic reactions.
Your last sentence was the key.  Metals like sodium and magesium react with water according to the following equations
$$\ce{2Na + 2H2O -&gt; 2NaOH +H2 + heat}$$
$$\ce{Mg + 2H2O -&gt; Mg(OH)2 +H2 + heat}$$
Both reactions produce hydrogen gas and a lot of heat.  As the hydrogen gas bubbles out of the water it mixes with atmospheric oxygen. The intense heat ignites the hydrogen-oxygen mixture and the mixture continues to burn (possibly explosively depending upon the quantities involved) as long as hydrogen continues to be generated.