Bonds form as atoms wish to obtain the octet rule/a full valence shell.
Well.firstly taking about:
for ex. When NaF is formed they are formed by sharing of electron,Sodium has an extra electron which it donates to Florine and there is the formation of a bond.
for ex. A carbon atom has valency 4 so it shares its electrons with 4 hydrogen atoms and completes it’s octate.
for ex. when a metal looses atom it gains apositive chargeand electrons roam in the lattice.