It's not just carbon dioxide. Just about any gas that contains oxygen enables magnesium to continue to burn because magnesium is strongly reducing enough to pull oxygen out of the gas molecules, displacing the other element. The reaction with carbon dioxide given by MaxW is typical. Water (vapor) also contains oxygen and thus water also fails to extinguish burning magnesium; in fact water vapor would lead to displacing hydrogen and creating an explosion risk. Burning magnesium also keeps going in nitrogen, forming a nitride.
It's not just magnesium, either. Other active metals such as calcium have similar properties. Special fire extinguishers, labeled Class D and containing dry powders that displace oxygen without generating other combustion reactions, are to be used to put metal fires out.