The correct explanation for why the valency of carbon is 4, despite having 6 electrons in total, is:
has 2 electrons in its first shell and 4 in the second shell.
Carbon has 2 electrons in its first shell (which can hold a maximum of 2 electrons) and 4 electrons in its outermost shell (the second shell), which can hold up to 8 electrons. Since it has 4 electrons in its outer shell and needs 4 more to fill that shell (to achieve a stable configuration similar to that of noble gases), it can form 4 covalent bonds by sharing these 4 electrons with other atoms. Thus, the valency of carbon is 4.