Hey
It IS likely that the depression, anxiety attacks and the awful things that happened in your past have set the stage for obsessive compulsive behaviour, and I dont doubt they are all related (it usually tends to be the case).
You come to the right place to find people who count.

It's one of the more common group of symptoms associated with OCD. You may not have distinct, full blown OCD, but many people experience mild cases of the condition or differing degrees of OC behaviour, especially when they suffer from depression or mental ill health. You have no reason to feel anything other than ok with yourself, because millions of people find they need to count also. Believe me, it is in no way odd.
The counting behaviours are quite typical of what you describe... they have a set pattern, and HAVE to follow certain characteristics. What they focus on is quite irrelevant, it is rather the nature of the counting that is suggestive of obsessive compulsiveness. And yeah, it can become so intergrated with daily life that you sometimes forget you are doing it.
Ive had similar counting obsessions before. If my "count" didnt end on an odd number it would somehow be "bad" or "wrong"... it would extend to things like the number of footsteps from my house to my car, the number of words in one of my college essays, etc.
A lot of people do this!
Steve