Why is magnesium atom smaller than atoms of both sodium and calcium?

The location of the outer electrons for Mg are in closer to the nucleus than of Sodium or Calcium.

To add to the correct answer from Bob Pursley, consider the electronic configurations.
11Na = 1s2, 2s2, 2p6, 3s1
12Mg = 1s2, 2s2, 2p6, 3s2
20Ca = 1s2, 2s2, 2p6, 3s2, 3p6, 4s2

The outer electron for Na "sees" a charge of +1 (11 protons in the nucleus shielded by 10 electrons from the inner shells) whereas the outer electrons for Mg "see" a +2 charge (12 protons in the nucleus shielded by 10 electrons from the inner shells). Thus the Mg electrons are drawn in further due to the increased charge.
For Ca, the outer electrons see a +2 charge, the same as Mg, (20 protons in the nucleus shielded by 18 electrons from the inner shells) BUT the outer electrons are further out(in the 4s shell instead of the 3s) and the attraction falls off because of the distance.

thanks

You're welcome! I'm glad I could help explain why the magnesium atom is smaller than the atoms of sodium and calcium. The key reason behind this is the location of the outer electrons and the effective nuclear charge experienced by those electrons.

In the case of sodium (Na), it has an atomic number of 11. Its electron configuration is 1s2, 2s2, 2p6, 3s1, meaning it has one electron in its outermost energy level (3s). These outer electrons "see" a charge of +1, which means they are attracted to the nucleus and determine the atomic size.

Magnesium (Mg) has an atomic number of 12 and an electron configuration of 1s2, 2s2, 2p6, 3s2. In the case of magnesium, its outer electrons "see" a charge of +2 due to the increased number of protons in the nucleus compared to sodium. This stronger positive charge pulls the outer electrons closer to the nucleus, resulting in a smaller atomic size compared to sodium.

Calcium (Ca) has an atomic number of 20 and an electron configuration of 1s2, 2s2, 2p6, 3s2, 3p6, 4s2. Like magnesium, the outer electrons of calcium also "see" a charge of +2 due to the number of protons in the nucleus. However, the difference lies in the fact that calcium's outer electrons are in the 4s orbital, which is further from the nucleus compared to the 3s orbital in magnesium. The increased distance reduces the attraction between the outer electrons and the nucleus, causing calcium to have a larger atomic size compared to magnesium.

So, the combination of the increased effective nuclear charge and the closer location of the outer electrons in magnesium makes its atomic size smaller than both sodium and calcium.