Why do people self-harm? - eviltoast

I don’t really understand why people do it. Not like “they’re doing it because they are depressed and feel bad”, I had depression myself but never had a call to injure myself. I hate pain, and doing something painful to myself while I’m already feeling bad doesn’t really sound appealing. So I don’t quite get what self-harm gives people so they keep doing it.

Like, is it a way to “ground” yourself and stop dissociating, or is it “just to feel anything at all”, or as a “punishment”, or something else?