atoms are made of 3 types of sub atomic particles; electrons, protons and neutrons

Of these particles, electrons are involved in the chemical reactions.

Therefore chemical properties of the element are determined by the electrons, and that too mostly the valence electrons. Valence electrons are the electrons in the outermost energy shell.

Atoms with same number of valence electrons have similar chemical properties. atoms having same number of valence electrons are classified into groups.

So elements of the same group have same number of valence electrons, hence similar chemical properties

Ca has 2 valence electrons so it belongs to group 2. Of the given elements

only Mg belongs to group 2. Therefore Mg has the most common properties with Ca