our brains run simulations of awful situations all the time as a diagnostic self-test system. The fact that we recoil in revulsion from destructive intrusive thoughts is a sign that we are still at least nominally sane. Those who yearn for peace prepare for war. Likewise, those who care for their loved ones prepare to face terrible events that might befall them.
Shin Sekai Yori is an light novel / anime about what happens when these thoughts have power and how a society might develop to control the destructive consequences of said thoughts.
Lol my mom and I have OCD. She's got a bit of this type, fortunately mine is a bit more of the I really really love filing and collecting things (data hoarding) borderline autistic type.
Don't be sorry for these intrusive thoughts. It's from our ancestors, when they could only survive through killing their offspring. It's an old part of your brain that plays devil's advocate. Use it, redirect it, of course, be aware, especially when you're a sleepwalker.