I've had trauma-induced OCD for decades. Repetitive counting is pretty common compulsive response to anxiety. Since the quarantine, I have found myself thinking I'm hungry, going to the refrigerator, counting every item in my refrigerator, then closing the door, deciding I'm not hungry anymore. I do this now 5 or 6 times a day. Since food scarcity was a serious problem when I was a child, I used to hoard food. I'd store canned goods under my bed and I couldn't sleep unless I counted them 10 times and divided the number up by the number of days in the week. If the number was greater than 1, I went to bed feeling safe.
I talked to my psychiatrist this week about my refrigerator obsession. He said the stories of national hoarding and panic buying were probably triggering trauma memories of scarcity. So, I'm counting items in my refrigerator. It's an anxiety/fear response. The thing is, I am terrified to eat the food. The count will lower. I've lost 8 lbs since the quarantine started because I don't want the count to drop. The standard treatment for OCD is an SSRI, but I can't take them. They make me wildly manic. So, we use Seroquel. It's ok, but I still have symptoms.
Having said all that, I do think your counting is an anxiety response. The counting is a form of relief. When the source of your anxiety is reduced, I'll bet your counting compulsion will also reduce.