I don't know if people have looked into obsessive compulsive behaviour and its relationship to religious rituals. I personally know a number of people who would restart their prayers several time (each prayer time, mind you) because they are worried that they missed a step.
Religious rituals like prayer often follow a set of procedures, usually clearly proscribed. For Muslims, ablutions, clean clothing is a must and the prayers follow a certain timeline daily. As a child, I was taught that there are many rules governing the prayer rituals and missing/screwing any will mean that I have to start from scratch.
It made me very anxious about prayers as a child; and I am sure there are many who had similar experience. For some, this anxiety spills over into adulthood, or rather, become transmogrified into obsessive compulsive disorder. OCD affects people across the board, regardless of faith (or lack of them) but I do wonder if emphasis on formalities and ritualistic behaviour has anything to do with the development of OCD.
You have people who wash their hands multiple times or wipe their feet or jiggle all doorknobs three times before entering and so on and so forth. If you ask them to reflect on when these behaviour pattern start to dominate their life, could they pinpoint it? Is it related to certain admonishments (wash your hands or you'll be eating germs!) or traumatic events (the passing of a loved one) or both?
For those who find difficulty in coping with a life bound by such compulsions, help is available. Counselling and help is offered by psychologists and psychiatrists. There is nothing to be ashamed of; we all have our quirks and escapes from the bell curve of normality.
For those who always find their thoughts dominted by was was or syak or uncertainty during prayer, do read what the lovely Dr Asri has to say about this. This is definitely one of the reasons he is my favourite religious scholar of this generation.