Dear student,
Actually the total number of electrons in sodium is not 20.
Total number of electrons in calcium is 20.
The electronic configuration is: 2, 8, 8, 2
It is because the absence of d subshell.
Upto calcium, the third shell can hold only a maximum of 8 electrons. But after calcium, due to the presence of d block, things change and then the third shell can hold a maximum of 18 electrons.
The reason behind this is that, the d block elements have (n-1)d subshell. Upto calcium the electrons get into 1s, 2s, 2p, 3s, 3p, and then 4s (not 3d...by aufbau principle). But after calcium, the electrons get into 3d subshell. d subshell have a maximum capacity of 10 electrons. So the third shell can have 8+10 electrons now. This is how it works.