In losing, gaining, or sharing electrons, atoms tend to acquire the electron configurations of noble gases.
This is incorporated into the “octet rule”, meaning the atoms tend to acquire a filled valence shell of eight electrons. (except H, Li and will have two electrons similar to He)