Arieri, there are several reasons why this happens. One of which could be a response to trauma (mind you I don't say this loosely).
If you have time, do check out my article How To Get Over Anyone No Matter How Long You've Loved Them. In this article, I explored how I got over a crush I loved for seven years.
The second article, The Heart Has A Mind of Its Own. Here I explored how I was trying my best to stop myself from falling for someone yet again.
I think you might find my perspective on this subject interesting.
Overall this was a great read. It made me chuckle too.