Answer:
The ionic compound should be neutral overall. For metals and nonmetals to react they have to lose their charges to reach to that neutrality. So we are trying to ensure the compound is neutral after they react. ( the reactants I mean)
Like Na+ whose has 1 electron to lose and Cl- who has one electron to gain to achieve stability are very compatible. So they cancel each other. +1 -1 = 0
Its the same concept for CaCl2. Ca has a 2+ charge and 1 Cl by it self, has a -1 charge. in order for neutrality to cancel each other timing Cl by 2 allows it to achieve the criteria to cancel the 2+ charge on Ca.
2 × -1= -2
So Ca 2+ +Cl 2- = 0
I hoped I explained it right