Calculate the cathode electrode potential in this redox reaction
The equation that corresponds to the standard reduction potential is:

$$\ce{Mg^{2+} + 2e- -&gt; Mg}$$

Notice that this is not the actual half reaction in your total equation, where magnesium is oxidized. But the book is determining the reduction potential, so the magnesium ion is a reactant not a product. In the reaction quotient, the concentration/activity of magnesium ion should be in the denominator.

I'm not sure I agree that we should choose the standard reduction potential as the electrode potential for the electrode where oxidation occurs, but at least the book is consistent.