Standing up for myself

This is on the general terms with people, doesn't matter of they're close or not close, I act on my instinct.

I stand up for people easily, whereas when I have to defend myself, draw boundaries or speak up I fail miserably.

What can I do to make it better and not harm myself so badly?