Not because they’re in love with each other, of course. Or are they? Maybe. Atoms form bonds because the outer most electrons, the valence electrons, are attracted to nearby atoms. When they get close enough the electrons are shared between the two atoms and the shells of the atoms fuse together.
When an electron is shared and spends most of the time near one of the two atoms, then you have an ionic bond, but when the electrons are equally shared among the atoms, then you get a covalent bond. The atoms can’t get around this situations and they will bond whenever they will meet other atoms.
The bond happen provided that the outermost electron shell is incomplete. If it is full, then no bonds will happen, like when you try to make a bond between iron and a noble gas. Not gonna happen.