The cause of OCD is not a clear so steps to prevent it are not clear either. Early diagnosis and treatment can lower the impact on your life.
References
Obsessive-Compulsive Disorder (OCD). EBSCO DynaMed website. Available at: https://www.dynamed.com/condition/obsessive-compulsive-disorder-ocd . Accessed January 13, 2020.
Obsessive-compulsive disorder (OCD). National Institute of Mental Health website. Available at: https://www.nimh.nih.gov/health/topics/obsessive-compulsive-disorder-ocd/index.shtml. Accessed January 13, 2020.