We know the reason why covalent bond is formed. It allows each atom to complete octet in the valence shell, and thus attain a noble gas electron configuration, which is extremely stable.
A covalent bond, is a chemical bond that involves contribution of electron(s) by participating atoms to make and share electron pair(s) between two atoms. These electron pairs are known as shared pairs or bonding pairs.
See this nice video about formation of covalent bonds.
The number of valence electrons decides the number of covalent bonds a particular atom can form.
We know that the first shell is filled with 2 electrons,
Most of any additional shells are filled with 8 electrons.
Hydrogen contains 1 valence electron. Its only shell can be filled with 2 electrons for stable configuration. So it forms 1 covalent bond.
Oxygen has a total of 6 valence electrons. To complete the octet it requires 2 more electrons. Therefore it can form a double covalent bond.
Nitrogen has a total of 5 valence electrons. To complete the octet it requires 3 more electrons. Therefore it can form a triple covalent bond.
A carbon atom has 6 electrons: 2 in the first shell, and 4 are left in the outermost valence electrons. So carbon can form 4 covalent bonds.
Chlorine has 17 electrons: Electron distribution being 2 + 8 + 7 in the valence shell. So it can form 1 covalent bond - by sharing 1 electron pair with another chlorine atom.