Almost no one ever considers why they are attracted to the people they are. Many become attached to significant others who display the same dysfunctional behavior in a series of unsatisfying relationships. Understanding this process can lead to true liberation and healthy and satisfying connections with a true partner.
Information on replaying experiences for childhood can be found in the work of Harville Hendrix:
https://coupleslearn.com/childhood-affecting-romantic-relationship/
Information on how childhood scripts affect us from Eric Berne's Transactional Analysis:
https://counsellingtutor.com/counselling-approaches/transactional-analysis/life-scripts-in-transactional-analysis/