The electronic configuration of the carbon atom is written as: 1s²2s²2p². Each s orbital can hold up to 2 electrons, while each p orbital hold up to 6 electrons. That means that the first two shells are closed, while the 4 electrons in the p-orbital is open. The 4 valence electrons of the carbon can bond with many other element, including carbon itself. This unique property is called catenation. That is why one borad field of chemistry, called organic chemistry, is dedicated solely to compounds containing carbon.