Answer:
Take for example I₂ (iodine)
Explanation:
It has only a pair of electrons between the iodine atoms in order to gain a stable arrangement of 8 electrons in its outer shell. It is sharing them, so it's a covalent bond as a single iodine atom cannot be stable on its own. It's a halogen and is a single covalently-bonded diatomic molecule.
Similarly, take oxygen. IT needs two pairs of electrons just so it can reach a stable outer shell of 8 electrons. If it doesn't then it cannot be stabilised so it must be bonded with another oxygen atom and share two electrons.