Atoms bond together to share outer electrons to become more stable. Like all things in nature, atoms naturally move to a more stable state, which is why atoms will bond without special circumstances. Not all atoms will bond with each other, typically only ions that need to gain or lose an outer electron, and atoms can form a covalent bond or ionic bond.
All atoms have orbitals that electrons stay within. Each orbital contains a specific number of electrons, and an atom will try to fill a lower orbital before creating a new outer shell. When the outer orbital is not full of electrons, atoms will look to either accept or give away electrons to obtain a full outer shell and become more stable.
A covalent bond is the type of bond usually formed between two or more nonmetal atoms. These atoms share their outer electrons to essentially fill all their outer orbitals and become more stable. The molecule as a whole may have a neutral charge or still be an ion.
When a metal atom bonds with a nonmetal atom, they usually form an ionic bond. The way to think of this is that the metal donates electrons to rid its outer shell of the few electrons it may hold, while the nonmetal atom accepts the electrons to fill up its outer orbital.