How can FeS2 be the formula of iron sulphide and CaC2 be the formula of calcium carbide?
What you call iron sulphide, in my opinion, is more appropriately referred to as or iron disulphide. 

If one were to assign oxidation states to each atom, an appropriate description would be  $\ce{Fe^2+}$ and $\ce{S_2^2−}$. This formalism recognizes that the sulfur atoms in pyrite occur in pairs with clear $\ce{S–S}$ bonds. These disulphide units can be viewed as derived from hydrogen disulfide, i.e $\ce{H2S2}$ (similar to hydrogen peroxide)

Take a look at the crystal structure (of pyrite): 

In the center of the cell a $\ce{S_2^2−}$ pair is seen in yellow. The $\ce{S}$ atoms have bonds with three $\ce{Fe}$ and one other $\ce{S}$ atom.

Contrast this with, $\ce{FeS}$, i.e Iron (II) Sulphide where the counter anion is what you would typically expect $\ce{S^2-}$. This is reflected in its crystal structure, which is the nickel arsenide structure:



The bonding situation is completely different in these two compounds and this is reflected in their chemical formulas. 

Similarly, for calcium carbide, the crystal structure is a tetragonally distorted $\ce{NaCl}$ lattice, comprised of discrete $\ce{Ca^2+}$
and discrete $\ce{C_2^-}$ ions.

Also, bear in mind what @Jon Custer said in his comment: 


  Because the 'rules' on valences are not firm rules. On the $\ce{Fe-S}$ binary phase diagram, $\ce{FeS2}$ exists as a line compound


Also, I'll briefly mention what he probably meant by a line compound:


Vertical lines such as the one seen here for $\ce{FeS2}$ indicate inter metallic compounds, which have precise chemical composition.

References


This article for the crystal structure of calcium carbide: http://pubs.acs.org.ejgw.nul.nagoya-u.ac.jp/doi/abs/10.1021/j100010a022
The crystal structures of pyrite and Iron (II) sulphide both come from their respective wikipedia pages here and here
The phase diagram comes from: http://www.minsocam.org/msa/collectors_corner/arc/scn1.htm (which further credits it to Ehlers, 1972, after Kullerud, 1967 The Interpretation of Geological Phase Diagrams, Fig. 217, p. 232)