How can atoms achieve a stable electron configurations?
Atoms are stable when they have eight valence electrons (two in the case of hydrogen). This is called having an octet. Only the noble gases have an octet of valence electrons naturally (two for helium, which is called a duet). Therefore, atoms that don't have an octet share their valence electrons with other atoms so that they each will have an octet (or duet in the case of hydrogen). This sharing of valence electrons is called covalent bonding, and takes place primarily between nonmetals. The valence electrons are in the outermost energy shell.
You can see in the diagram of a water molecule below, that each hydrogen atom had one electron, identified as an x, and the oxygen atom had 6 valence electrons identified as colored circles. (The inner two electrons in the oxygen atom are not valence electrons.) Each hydrogen atom has shared its valence electron with an individual oxygen atom from its valence shell, forming a covalent bond. You can see that each hydrogen atom now has a duet of valence electrons, making them stable, and the oxygen atom now has an octet of valence electrons, making it stable.