The carbide anion is C2 with a 2- charge Ca2-2therefore, Ca(+2) + C2(-2) creates CaC2 because the Carbide being C2 and not just C
in other words, the carbide ion has 2 carbon atoms with a -2 charge
looking at other anions, we see that O has a -2 charge, Cl has a -1 charge etc. when combining with Ca+2, the charges lose their signs and cross over to the other atom
Ca+2 + Cl-1 --> CaCl2
Ca+2 + O-2 --> CaO
Ca+2 + C2-2 the charges are equal so they cancel out but the carbide ion is 2 C atoms therefore, C2 and when added to Ca, even though the charges cancel out, one cannot cancel out the number of atoms present. therefore, CaC2
if we were looking at sodium carbide, we would have the Na+1 ion binding to the C2-2 ion resulting in Na2C2
In other words ,it is covalent compound .
there are two valencies of calcium & carbon has four valencies
for satisfying four valencies of C-atom the structure is as follows ---
C
||| \Ca
C /
i.e. two C- atoms are attached to each other by triple bond
& Ca -atom is attached to both C- atoms by single bond