For your first question, sentences #2 and #3 are grammatically correct, but have different meanings.
2. She's dangerous to herself. - This means that she emotionally/physically/mentally harms herself.
3. She's dangerous by herself. - This either means that she is in danger when she's alone, or she is dangerous to others even when she is alone, more wiggle room with the meaning.
For your second question, the "subject" noun should be a normal pronoun (I/you/he/she/it/they/we). The second pronoun is reflective (myself/yourself/himself/herself/itself/themselves/ourselves). Now for some deeper meanings:
1. You did it to yourself, bear the consequences. - This is natural, the meaning is clear, and it is the only sentence that conveys that someone did something negative that effects them.
2. You did it yourself! - This is natural, but would often be said like a question. "You did it yourself?" "Yes!" "Wow, you did it!"
3. You did it by yourself! - This sounds more congratulatory than condemning - like something you would say to a kid who used the toilet alone for the first time.
Hope this helps!