It’s a kinda coping mechanism, but not a good one at all, and it is like an addiction.
A quote from Ashton_Killjoy:
“I tend to get urges to when I feel overwhelming amounts of stress or guilt, I don't really know why, but it seems to me that ppl who self harm feel the need to inflict physical pain on themselves to distract them from their mental/emotional pain, or feel like they deserve to be hurt like that. Self harm is actually a coping skill, just not a healthy one. Sort of like drinking or drugs, and much like those it can be difficult to stop once you begin.”