I think that people who have poor boundaries amd cant assert themselves don't trust themselves to make a judgement as to whether the other person is in the wrong. This, I think, is due to having your own sense of injustice eroded at a young age.
Here is what I have realised over time:
Other people aren't more important than me and they don't get to have priority treatment and override social norms so they can say/do whatever they want.
The people that we often want to be nice to when they are walking over us, are walking over us because they don't care about us. It makes no sense to try to appease someone who doesn't respect you at all.
Develop red flags so that you can shut users, CFs and bullies down before they start. When you get the feeling that someone is seeing how far they can push you, you will feel a kind of shift inside yourself. Listen to it and don't brush it off. Every time someone has tried to take the mock out of me, I recognised it. Trust that instinct.
If you feel like someone is taking the piss, they probably are. Don't give them more time to prove you right. Act decisively and decide that you will be very wary of that person and have a boundary phrase up your sleeve, ready to unleash at a moment's notice.
Finally, think of future you. My mum once told me that sometimes you have to be brave and speak up for yourself, even when you feel scared, because you want to look back and respect how you handled it. You don't want to look back and kick yourself for letting someone walk over you.
I was picked on a lot as a teenager and had such a toxic friendship in my early twenties that I still have nightmares about her now, 20 years later. I was a complete walkover and let people push me around, but I now have a very sensitive siren that goes off when I feel like I'm at risk again. I am then on the (firm but polite) defense very quickly and nobody ever tries it on anymore. I don't mean that I'm hard or something now, I'm not, but my boundaries are really strong and I think people sense it.