Because it's a pattern of thinking and feeling, which you likely learned as a child.
This is right on the money, at least as far as my experience is concerned. When I finally decided to step away from the relationship with my ex for good, and had discussed patterns of thought and behaviour with my therapist, I thought, "Ok, good. I'm ready for the hard work of developing new patterns of behaviour, laying down new tracks and paths in my mind and heart." Plasticity of the brain and all that.
And that really is the way forward. But when the emotions hit and the familiar patterns pull us in with their relentless gravitational force ... .well, it's just so much harder than we imagine when we're feeling strong and determined to stick with our new approach. Inevitably, we fall back into old patterns sometimes. As Moselle suggests, try to find other outlets for that need to connect with your ex. Friends, family, meet-up groups, volunteering, whatever it might be. It might feel like a poor substitute at first, but that's all part of setting down healthier patterns of behaviour, which in turn lead to healthier patterns of thought and emotion.