To answer this we need to compare the two ions. The main difference between the two ions is the number of protons in the nucleus - Magnesium has one more proton than Sodium, however, if you look at the electron configurations of the two, they will be the same, so called isoelectronic (i.e. 1s^2 2s^2 2p^6). The higher positive charge on the nucleus in magnesium causes a stronger attraction on the negatively charged electrons ($$F \propto q_1 q_2$$), and so the ion has a smaller ionic radius.