D is correct, there are two phosphate ions in a molecule of magnesium phosphate,
This is an example of a polyatomic ionic compound. Your description of phosphorous and oxygen behaving as one charged particle is the definition of a polyatomic ion, in this case the phosphate ion.
The subscript 4 on PO4 indicates that four oxygen atoms are bonded to each phosphorous atom in the polyatomic ion. The subscript 2 outside the parentheses indicates two phosphate ions. Parentheses are used to show that the subscript applies to the entire charged particle.
The reason there are two phosphate ions is that the phosphate ion has a charge of -3 and the magnesium ion has a charge of +2. The formula results in a neutral compound with six positive charges cancelling out six negative charges:
(3)(+2) = (2)(-3)
It's more correct to say that there are two phosphate ions in a formula unit of magnesium phosphate because ionic compounds don't exist as individual molecules.