Atoms without a full octet are unstable and highly reactive. They will either get rid of extra electrons or they will gain enough electrons to fill their valence shell.
There are two main types of chemical bonds: covalent bonds and ionic bonds.
In a covalent bond, two atoms share electrons so that they can complete their octets.
In the example below hydrogen starts with 1 electron and wants to achieve 2 in its valence shell (remember that hydrogen is an exception to the octet rule). Carbon starts with 4 and wants to gain 4 more to have a full octet.
Each hydrogen shares 1 electron with carbon and carbon shares 1 electron with them in return. The result is that all 5 atoms have a complete octet and stable valence shell.
In an ionic bond, one atom takes an electron completely from the other atom. What holds the two ions together is the attraction between the opposite charges.