For simple explanation I will talk about only a representative element such as :
11Na : 1
19K : 1
you can see that Na and K was in the same group because their valance electron were in s orbital and only has 1 electron.
So if you do electron configuration with column 2 of periodic table you will also get 2 valance eleectrons in s orbital for Mg and Ca etc.