When balancing a chemical equation, the goal is to get the same number of atoms of each element on each side. We do that by adding coefficients. The equation is balanced when there are equal numbers of each element on both sides of the equation. We do this in order to satisfy the law of conservation of matter/mass.
First look at the polyatomic phosphate ion
Now look at magnesium hydroxide
Now look at the H atoms. There are 6 H atoms on the left side and 2 on the right side. Add a coefficient of 6 in front of water
Now look at the O atoms. There are 14 O atoms on both sides, so the oxygen is balanced.
NOTE: Notice that I did not change any of the formulas. By adding coefficients, I changed the amounts of the compounds only.