That certainly sounds like an obsession and compulsion. The feeling OCD gives you is always really scary. Unfortunately, the more the compulsion is performed, the more often you feel anxious not doing it.
The only way to start getting better is by being aware of these thoughts as strictly coming from OCD, and the urge to perform a compulsion in the same way.
Eventually the realization that the thoughts aren’t real and the compulsion isn’t necessary will sink in. That’s a really simplified version of the process, but maybe bringing some awareness to it can be your first step!
I would recommend working with a therapist if possible. If that’s not possible for you, you can always post here if you need some support! 😁