Electronic configuration:
The first two electrons fit in each sp orbital as per to Hund's rule like that each orbital has a single unpaired electron, for carbon. This leaves two electrons that can be paired up in the half-filled sp orbitals or located in the vacant 2py and 2pz orbitals. The energy variation among the orbitals is small and thus it is easy for the electrons to fit into the higher energy orbitals as compared to pair up. This directs to two half-filled sp orbitals and two half-filled 2p orbitals, and thus four bonds are possible.