I've had a strange, repetitive fascination with being shot for decades now. It mostly comes to me when I'm struggling to get to sleep, and always begins with feeling like I've been asked the question; "Have you ever been shot?". I have no idea where it comes from; I'm not a shoot-em-up game player, I've never watched many war or crime movies, and I live somewhere where gun crime is, thankfully, extremely rare. The scenario varies a lot, and it's usually no particular person that I imagine shooting me. My brain just seems endlessly fascinated by what it would feel like and what I would do, even though I'm aware that I can't possibly know that, and even in the fantasies, I'm far from being some kind of super-heroic Die Hard kind of character.
I once knew a guy who had a similar thing about power-tools, especially the big tooling that you get in factories. He told me that he experienced the compulsion to stick his hand into them, not as a form of self-harm, but just out of curiosity about "what it would be like."
If the thoughts are frightening you, then it's the kind of thing that counselling might help you with. But so long as you're not thinking of self-harming or believe that you deserve that as a form of punishment for something, I don't think it's anything to be too concerned about - everyone has irrational thoughts at times, and you recognise that they are irrational; that's the most important thing.
_________________
When you are fighting an invisible monster, first throw a bucket of paint over it.