I struggle with the very same things you do and a lot of other people do too, and having started to discover during prayer the root of my own obsessive thoughts, maybe what I’ve learned can help you.
I’m definitely not a medical professional though, so please only take this based off of my own personal experiences with OCD and anxiety.
Firstly, these thoughts aren’t sinful; if you clearly desired the content of those thoughts and willfully encouraged them, they would be; but obviously as they’re causing you anguish and upset every time they appear they aren’t (even when it feels like it is). Remember, you can’t accidentally sin - it has to be a clear and willful act, which this isn’t, so don’t worry.
Onto some root causes, the main thing seems to be anxiety and worry, and also control. As OCD is an anxiety disorder, the driving force behind it is fear - usually the fear of losing control of a situation. All the little OCD rituals and obsessive thoughts are your brain’s way of attempting to take control of a situation (if I do this action, this won’t happen e.t.c.) that is impossible to control; such as controlling every thought that enters a person’s head.
The greater the fear the worse it gets, such as worrying about blasphemy of the Holy Spirit. As its an incredibly serious matter but yet to an anxious mind it could happen by accident at any moment (even though it won’t), the fear of the unknown makes your mind fabricate it and make up something to ‘ground’ itself on, as if making it real takes away the unknown (like always imagining and worrying about the worst possible outcome to a situation, to make the possibility of it happening less scary).
An example could be someone concerned about their kids being hurt or attacked could have a fleeting thought about themselves injuring their own children on purpose; most people would dismiss a thought like that as ridiculous and have no more problems with it, but someone who has that difficulty with anxiety and latching onto thoughts even when you don’t want to will end up reinforcing the thought every time they have an emotional reaction to it - the more strongly you react to it the more firmly it’ll appear, like your grey elephant example.
Rest assured, although the thoughts themselves are horrible you aren’t to blame for them and God knows that; the more you allow yourself to trust Him more and more and put yourself under His control the easier things will be. There will be bad periods and good periods, but I promise you it gets easier with time. The best thing to do would be to pray more about it and do your best to stay relaxed and detached from whatever horrible thoughts may appear; its also helpful to continue to remind yourself that as you’re not consenting to any of it you aren’t being held accountable for it. I’ll be praying for you also.