I’ll send the Q to Dr. Lawrence.
I do believe people check to reduce anxiety. They otherwise will obsess about whatever it is, and complete the behavior helps them check that off their list (no pun intended) so they can move on. I do very minor checking about locking doors and things that can catch fire like my curling iron. I don’t qualify as OCD, but I do go back and check those few things until I feel very sure they are ok. I think it can be very extreme where it is not enough to know the door os locked, but also the routine of going to the door, turning the lock, pushing on the locked door, but then a second and a third time doing the entire routine, when it is obviously locked. The routine has a calming affect I assume.
I think it might in some cases be also similar to an addiction where the obsession and compulsive behaviors avoid dealing with other traumatic or upsetting things in life.
There does seem to be some wiring in the brain related to compulsive behaviors and some medications can help.
As you know I am not in the psych field, just giving you what I know about it and also my take on the condition.