Carbon is present in group 14th of the periodic table and it’s ground state electronic configuration shows that carbon has 2 electrons in it’s outermost shell and it should be diavalent but carbon is tetravalent means it can form 4 covalent bonds with other atoms .
Carbon has 1s2,2s2,2p2 ground state elctronic configuration but when energy is provided one electron from the 2s2 orbital jump into 2p orbital and now carbon have four half filled orbitals and can form four covalent bonds .That’s the reason why carbon is tetravalent.
In methane carbon forms covalent bond with four hydrogen atoms .