Hello mat007: Thank you for bringing your concern here to PC. I noticed this is your first post. So... welcome to Psych Central.
We here on PC cannot offer mental health diagnoses. Plus I'm not a mental health professional. So I can't suggest to you what may be the cause of the difficulties you've experienced. Perhaps other members may have some insights or similar experiences they can share. In the meantime one thing you might do, here on PC, is to take some of the quizzes & tests that on offer. Here's a link to the listing of quizzes & tests that are available:
Psychological Quizzes and Tests
Here are links to 6 articles, from Psych Central's archives, that talk about living with OCD & how to manage obsessive thoughts:
Living with Obsessive-Compulsive Disorder | Psych Central
Coping with Obsessive Thoughts
How You Can Overcome Intrusive Thoughts | Dialectical Behavior Therapy Understood
9 Ways to Let Go of Stuck Thoughts
https://psychcentral.com/blog/5-ways...dium=popular17
https://psychcentral.com/blog/four-s...sive-disorder/
I hope you find PC to be of benefit.