<>
yourself: without help
by yourself : without help OR alone; when others are not with you
If you want the meaning alone, you need by. Context also plays a role.
I did it myself. (without help)
I did it by myself. (without help)
I did it while I was by myself. (while I was alone) (Note that another clue to meaning is a temporal expression like while.)
____________
Only the version with by allows the intensifier all.
*He built the table all himself.
He built the table himself. (without help)
He built the table all by himself. (completely without help)
Our son was sick and stayed home from school today. The poor kid had to play all by himself today. (completely alone; it's not likely that a child needs help to play!)
-- I need to buy a few things in this shop. Do you want to come in with me?
-- No. I'll just stay in the car by myself and wait for you. (Note how context tells us it's alone; it's not likely I need help to stay and wait.) (by myself is completely unnecessary here, of course. I used it only as an illustration.)
-- OK. I won't be long.
_________
In the plural, the meaning alone isn't quite literally true, of course. by ourselves (just us; no other people)
CJ