Carbon is in Group 4 of the periodic table, so its atoms have four electrons in their outer shell. To get a full outer shell, a carbon atom shares each of these four electrons with another atom. A shared pair of electrons is a covalent bond, so carbon forms four covalent bonds.
In methane, CH4, one carbon atom is joined to four hydrogen atoms by four single covalent bonds. Carbon can also bond to other carbon atoms, and to atoms such as oxygen, chlorine and nitrogen. In carbon dioxide each carbon atom forms two double bonds with oxygen atoms. A double bond counts as two of carbon's bonds, so the total is still four.