sorry i will rephrase the question.

what is the chemistry behind these elements to give them these qualities and make them react the way they do with like water and such.

1)magnesium
2)calcium
3)potassium
4)sodium

Mg and Ca have only two electrons in the outside shell. K and Na have only one All are easily removed (Mg and Ca less so than K and Na) so they are quite reactive.