What the hell is up with my body and pain!??

So when I’m in pain, literally any kind, physical or emotional. I have this urge to hurt myself in another area, but I don’t know why. And I’ve always been like this, even when I was little. And it’s not like I want to hurt myself its just as if my body wants to neutralize the pain by making me feel pain in another part of my body. Do you guys know why I’m like this?