Why do some people want to hurt themselves when they are upset or frustrated?

Defense Mechanism. There are a number of theories as to why a person would want to hurt themselves when they are upset or frustrated. In the act of hurting oneself the brain releases endorphins that can bring a sense of calm and/or relief from negative emotions. Hurting oneself to spare hurting another. Due to emotional trauma a person may feel numb and injury reassures their existence. Attention seeking behavior.
DEPRESSION. They are not in their right mind. Sometimes they are depressed not only do they hurt themselves, they end up killing themselves.