It's a coping mechanism and it's not only men who do it.
You keep a certain distance from a person you like because you're afraid they will hurt you. As long as you aren't overly close, they can't hurt your feelings - at least as much.
Heartaches are a *****, basically, and we will do everything we can to avoid them.