A Comparative Mechanistic Study on the Intercalation Reactions of Mg2+ and Li+ Ions into (Mg0.5Ni0.5)3(PO4)2