Why is self harm a coping mechanism?

Like where as a species and how did harming yourself become something that is comforting to people. I mean absolutely no disrespect and I struggle with it so I know alot about it first hand but I just don't understand where In our minds makes it comforting?