You don't attract people like these men and your friend, but you do keep them when others would have told them to fuck off.
Person A (let's call her Alice) has a high self-esteem and believes they are worthy of love and respect. Person B (Bea) is their identical twin but was separated at birth and grew up with low self-esteem and feeling 'not good enough'.
Like a Sliding Doors scenario they meet the exact same people dating and socially.
When Alice spots red flags they trust themselves to know how they deserve to be treated. They have strong personal boundaries and aren't afraid to walk away pretty early on if people cross them because they trust that better friendships and relationships will come. As a result, Alice only has people in their life who they feel they can trust and that add something to their lives. If you really dug deep they'll be able to remember a few random encounters or short lived friendships/relationships with people who they didn't click with or where there was a weird red flag of some kind that made them back off. These have made an occasional amusing story at the pub told to their group of lovely mates.
Alice has a lovely relationship with a decent guy and a small but perfectly formed group of close friends. Alice is grateful but doesn't even think about whether they 'deserve' this or not, because having good relationships is natural to them.
Bea also spots red flags but because of their low self-esteem they doubt themselves - "maybe what that person said wasn't that rude", "maybe I'm being over-sensitive", "maybe that guy was just having a bad day and I was being annoying".
So multiple red flags pass by which are noticed but buried. Sometimes the red flags are brought up by Bea, but the other people sense she can be gaslighted into feeling that she's the one with the problem and can even sometimes make her apologise for it (which they do, because they are emotionally unbalanced for their own personal reasons).
Deep down, Bea doesn't feel fully 'good enough' and worthy of being treated well, maybe they didn't have a great relationship with both parents which means they don't have a solid basis of how a great relationship (platonic or romantic) should feel.
This means Bea's life is full of the assholes that Alice walked away from. Bea has less nice people in their life because their time is being wasted on the assholes, leaving less time and room to meet and grow new friendships and relationships with decent people.
Bea wonders what's wrong with them that they attract so many horrible people and, because they have low self-esteem already, interprets this to mean that there is something fundamentally 'not good enough' about them...like they always knew.