Covalent bonds between atoms can be single, with two electrons shared; double, with four electrons shared; or triple bonds, with six electrons shared. The more electrons that are shared by two atoms, the stronger their bond is, with a triple bond, such as is found in nitrogen gas, requiring a great deal of energy to break. For single-element compounds like nitrogen gas, the type of bond tends to match the number, up to three, of electrons required to complete the neutral element's outer valence shell.
While electron valence shells are complicated within the transition metals, in many common elements, the outer electron shells are relatively simple and follow a predictable pattern. Most notably, the shells of these elements are only fully stable with two, in the case of hydrogen and helium only, or eight electrons. In cases which are close to having complete outer shells, such as sodium, which can lose one electron and thus an entire unstable shell, or chlorine, which can take one extra electron to complete its shell. Other elements, however, do not tend to do this because each electron gained or lost decreases their overall stability as they become more and more charged. Atoms always seek stability, and for most elements this is more easily accomplished through forming covalent bonds than through losing or acquiring electrons.