It looks like you are suffering from counting OCD in this people count without thinking of a specific number. Different people count different things like some count their steps, tiles, cars passing by, numbers, alphabets, etc. I would recommend you see a doctor or therapist as therapy with medicines are the best treatment for OCD.
You can read these articles on counting OCD and relate to your thoughts
Counting Numbers OCD: Symptoms and Treatment | NOCD
OCD Types | Facts and Info | New England OCD Institute