Because of the difference in electronegativity between calcium and nitrogen.
Electronegativity is an ability atoms have to attract bond electrons towards themselves.
In other words, when two atoms bond, the difference in electronegativity between those two atoms will determine whether or not the bonding electrons are shared equally or not.
If the difference in electronegativity between two atoms is high enough, the more electronegative atom will attract the bonding electrons more.
In the case of calcium and nitrogen, the difference in electronegativity is so large (2.04) that the bonding electrons spend almost all their time on the nitrogen atom.
This leads to the formation of ions. The strong electrostatic attraction that develops between the positively charged ions and the negatively charged ions will keep them bonded.
Because calcium loses 2 electrons to become
As a result, calcium nitride,