These are reflexive pronouns. One person or thing: myself, yourself, himself, herself, itself. More than one: ourselves, yourselves, themselves.
-self and -selves
The cat is washing itself.
The children dressed themselves.
Try it: Man: How was the party? Woman: Great! The kids really enjoyed ___. Choose what the woman says. (them / ourselves / themselves) Answer: themselves — The kids had fun, so they enjoyed themselves.
Back to the same person
When someone does something to the same person, use a reflexive pronoun (myself, yourself…): I hurt myself.
I hurt myself.
He's talking to himself.
Not "I hurt me." — say "I hurt myself.". The same person does it and gets hurt, so myself.
Try it: Woman: You made dinner for everyone? Man: Yes, and I made ___ a big dessert, too! Choose what the man says. (me / myself / yourself) Answer: myself — He made the dessert for the same person, himself, so he says myself.
By myself
Say by myself when you do something with no one else. It works with every reflexive pronoun: by yourself, by herself, by ourselves.
I like to walk by myself.
Can you do it by yourself?
Try it: Man: Is anyone going with you to the concert? Woman: No, I'm going ___. That's fine! Choose what the woman says. (with my sister / by myself / by yourself) Answer: by myself — Nobody is going with her, so she says by myself.
The same person, or someone else?
The same person: a reflexive pronoun (myself, herself, themselves). Someone else: an object pronoun (me, her, them).
She looked at herself in the mirror. (the same woman)
She looked at her and said hello. (another woman)
Try it: Woman: Why is your sister so happy? Man: Her husband bought ___ some flowers. Choose what the man says. (herself / her / himself) Answer: her — The flowers are for someone else, his sister, so he says her.