When people cut themselves, they first will feel the pain. This pain is a signal to the body to try to stop the cause of the pain. But for stone-age people, it could be vital for survival to continue to fight or flee to a secure place. Because of this, morphine-like substances are released in the body when we cut ourselves. These act on the reward center in the brain and suppresses feelings of distress in similar ways as narcotics do.
The act of cutting oneself influences the reward center in the brain and gives a temporary relief. You get away from the dull reality and the unbearable feelings and flee into nicer imaginations. Also anorexia can in similar ways numb pain. When you are starving, you get "high" in similar ways as when taking amphetamines.
Why is anorexia and cutting bad methods? If you allow yourself to experience unbearable feelings, you can attack your problems constructively and solve them. By working at solving the problems of life, you will become a happier person.
If, instead of working on your problems, you use a fast path to happiness by starving, cutting, binge eating or substance abuse, you just deaden the pain, but will not grow as a person. Life becomes a dead end, where the only result is a frustrated life, plus, maybe, ugly scars on your arms and legs.
Self-cutting can be treated with medicines, both SSRI-medicines and Naltrexone help - best in combinaion with psychotherapy.