I was on treatment for a while, with the correct medication for my anxiety disorder, which really helped. With a clear head and my brain chemicals in a more stable state, I was able to truly reflect on my behavior and see what I could improve on, and what was not my fault.
Lots of alone time helped as well. No desperation to fall in love, no desperation to get laid. No need to get attached to people just because I was lonely. Learned to love my own company and live with myself. Made me realize that I'm whole, even when single, and I don't need another person to "complete me".
All that said, it's an ongoing journey. If meet someone who lacks introspection and is a mess, I get triggered and unwillingly dip my toes in the murky FA waters.