Atoms bond when the interaction creates a lower-energy arrangement than the separated atoms.
Stability is an energy question
Attraction between nuclei and electrons competes with repulsion between like charges.
Sharing and transfer
Covalent and ionic models emphasize different electron arrangements, but both describe how electrostatic interactions reshape energy.
Read the potential-energy curve
At large separation, interaction energy is near zero. As atoms approach, electron–nucleus attractions lower the energy. At very short distance, nuclear repulsion, electron repulsion, and quantum confinement raise it steeply. The minimum defines the equilibrium bond length.
Models form a continuum
Ionic and covalent are limiting descriptions of electron density. Electronegativity, orbital overlap, symmetry, and the surrounding molecular environment all affect the actual distribution.
Check your understanding
Why does attraction not collapse two nuclei together?