Atoms join together due to their opposite charges attracting each other primarily through ionic bonds. In ionic bonds, one atom donates an electron to another, resulting in the formation of charged ions that attract each other due to their opposite charges.
Hydrogen bonds involve a slightly different mechanism, as they are not formed by the direct transfer of electrons but rather through the attraction between a hydrogen atom bonded to an electronegative atom and another electronegative atom.
Therefore, the correct answer from the provided options that describes bonds formed due to opposite charges attracting each other is:
ionic bonds and hydrogen bonds.