As humans we tend to migrate towards situations that we are most familiar with. If you find yourself repeating behaviors that you yourself find frustrating and painful, then you might seek out what it is you are truly and unknowingly seeking to fulfill. My advice, and I don't at all mean this in any negative context, is to seek therapy to get to the root cause.
In my case (and your situation will be different), after three one sided attractions (several years apart) and feeling pretty frustrated about it, I decided to seek out answers briefly through informal avenues and then through more structured therapy. It was one of the best and most enlightening experiences of my life. I highly recommend it to anyone seeking to know their truth.
Something about those three separate and wholly different individuals, their mannerism and behavior (not referring to anything negative) was triggering a deep seated need in me. At the time I was not aware of what the need was. I just know I was always disappointed and frustrated when they could not or would not deliver what I needed from them.
One day, I was sitting on the proverbial park bench thinking about things when I suddenly had an epiphany moment, one of those lightening bolt moments when I was suddenly and completely aware of the root cause of my behavior. I suddenly knew what I was seeking. It floored me. When I recognized it, the effect was immediate and dramatic and my behavior altered with that knowledge.
There in the persona of those three individuals was that which I had always but unknowingly been seeking...., a relationship with my father. You might scoff at that, thinking it corny or whatever, but for me, it was my truth. I am not talking about a sexual relationship (it was never that) but, rather an emotional one.
My father was former Navy man. In my early years he was away a great deal of the time. Around age 8-9, he was around moreso than before and yet, while he was "there" in my life he was not "there" for me....if that makes sense. He was emotionally unavailable to me. When he passed in '82, I was left with an unarticulated void in my psyche.
Some 4-5 years later, after I moved from home for the last time and on my own starting to explore my feelings for others, it was the persona's of those three guys, their "closeness" to me, yet their emotional unavailability to me that was triggering that familiar deep seated yearning from my younger years.
Like I said we all tend to migrate towards those things or situations that evoke familiar feelings in us, good or bad. Dysfunctional people tend to do that. When I recognized my behavior for what it was, it was like being freed. I was able to alter my behavior for the better. Now, that being said, I wasn't cured over night (or perhaps ever). I also know now it wasn't always "just me" getting something out of the one-sided relationships. In hindsight, I also now know that it takes two to tango, those guys were benefiting too, likely unknowingly, in some unknown to me way.
My point in sharing this....seek out your truth. There's something there that is causing your behavior, a repeating behavior. If you choose to seek it out, when you find it, embrace it, work with it! It will free you up to move on to other healthier things in life.
Good luck with your journey, however you choose to move forward!