Why does the distance between atoms in a hydrogen bond impact the strength of the bond? Wouldn't the distance be irrelevant as after they are attracted they will just close the gap? E.g. once 2 magnets are close enough to be attracted, isn't the distance irrelevant to the strength of the bond between the magnets as they will just become flush against each other, making the distance between any 2 magnets that are attracted to each other equal.

Or is it perhaps talking about the other groups stopping the hydrogen and other atom becoming close?



Context:

Of the following, the factor that has the least effect on the strenght of a hydrogen bond in a molecule is the 


type of atom to which the hydrogen atom is covalently bonded.
distance that the hydrogen atom is from the atom on the other part of the molecule
number of other hydrogen atoms atttracted to the atom on the other part of the molecule
type of atom in the other part of the molecule to which the hydrogen atom is attracted


(answer is 3, hence 2 must have some effect).
The main attractive force between the nuclei and the electrons is electromagnetic, positive and negative attracting. When two atoms are "pushed" together each one shares its own electrons with the other one's nuclei, and they bond. So why wouldn't they nuclei just get as close to each other as possible, so that they each would feel as many electrons as possible? At the same time, the electrons are repelling each other, and the nuclei repel (same charges repel). The bond length is a function of this "equilibrium" that is reached between the attraction of the nuclei to the electrons, and the repelling of the nuclei  and the repelling of the electrons. Therefore, if they begin to "close the gap" as you say, there will be more repelling than attracting, and they will move farther away from each other, and return to the lowest energy distance, the original bond length.