Carbon has the unique property of Catenation (forming a long chain) and also it is Tetra-valent ( can form 4 bonds).
Since donation or acceptance of four electron is very difficult, hence the other way to complete the octet is the sharing of electron which results in the Covalent bond formation.