How to avoid ever losing yourself in a relationship?

In my previous relationship, In the beginning, I was not that deeply invested in him and as the time went by and I fell deeper and deeper into him and the more I fell in love, the more I thought he was amazing and I didn’t deserve him, and that I had to earn his love in some way, because he was too good, I made myself believe this to the point that my happiness got dependent on him and everything was revolving around him, I lost myself because I was concentrated how to make him happy. I was anxious if he was moody, I was wondering if I have done anything wrong, if I had been a bad girlfriend, if there’s something I need to do better, and I was so lost in these thoughts that I lost the ability to be a partner, I started looking up to him, while in the beginning he was the one looking up to me and that was better I think, but then we changed the roles and I was so scared of losing him that I lost a sense of myself because instead of my own priorities I prioritized him and I no longer knew what I wanted or where was I…

I am scared of it ever happening, I don’t want to experience something like that again… What advice would you give me? I tend to be attracted to the men who awaken exactly same feelings into me…

But I can no longer allow myself to stop prioritizing myself again. If break up taught me anything was that It’s me, I am the priority, I stay with myself, once everyone leaves, I soothe my heart, I pick myself up, I am responsible for my own happiness and I am stronger than I could have ever imagined. And that I should be entering any relationship with self love and dignity and not thinking that I need to somehow earn love…

My mom often tells me “You need to be more successful, you need this, you need that… be loved by a man like this…”

It hurts me to be heard that, because I think we shouldn’t be thinking we need to earn anyone’s love, I think I deserve love just the way I am and I shouldn’t be constantly working on myself to deserve it.

Updates
1 y
Initially, I believed I deserved my ex’s love, but my mom, who I am very close to, trying to inspire me to be more successful, would often tell me “He’s that kind of man. If you want a man like this to stay with you, you should be this… and this… and this…” and would tell me all the things I am not. Trying to motivate me become better… But I am as I am and I deserve love as I am I think. I should stop talking with my mom and toxic people about my relationships.
How to avoid ever losing yourself in a relationship?
Post Opinion