Why do different elements form different types of carbides?
According to wikipedia,


  Carbides can be generally classified by chemical bonding type as
  follows: 
  
  
  salt-like carbides
  covalent carbides
  interstitial carbides
  "intermediate" transition metal carbides.
  


This type of classification is based on the electronegativity of the element to which the carbon is bonded.

According to this site:-


  The most electropositive metals form ionic or
  saltlike carbides, the transition metals in the middle of the periodic
  table tend to form what are called interstitial carbides, and the
  nonmetals of electronegativity similar to that of carbon form covalent
  or molecular carbides.


Actually credits goes to @jatin  who gave me an important hint:-


  You might wanna consider diagonal relationship which accounts for
  similarities between those particular metals.


As you can see that Li and Mg, Na and Ca and Be and Al all form diagonal element pairs. So, they are expected to have similar properties. So, considering their electronegativity, the diagonal element pairs have almost same value (though Li and Mg electronegativity is quite different). So they form similar type of carbide.

 

(original picture)

As for the intestitial carbides, @bon said that


  Insterstitial carbides only form with large cations (Ti and W), as you might
  expect if the anion (very small) to fit in the spaces in the cation crystal
  structure.