This is not the sort of question that can be answered easily. It could be argued that only qualified pyschologists and psychiatrists and other specialist medicos can answer it. However, I do know how a simple neurosis can form. It can form simply out of an action repeated a number of times until one suddenly believes that if that action is not undertaken, a certainl mental pressure or uneasiness occurs. Let me give you an example.
Suppose you walk up the street every day at at a certain point you decide you'll touch a fence post. It might have been just an impulse but you did it. The next day you walk up and you touch that fence post a second time. Then on the third and fourth days the same. It gets to the point that you always touch that fence post as you walk past it.
One day you can't remember if you touched it or not. Oh-oh. I'd better just nick back and touch it. And you give into this impulse to. You feel uneasy because you didn't touch the fence post. This is the beginning of neurotic behaviour. Your common sense tells you you're being ridicuous, but you can't seem to help yourself.
This sort of behaviour is far more common than you think. The 'rabbits foot' for luck by the bomber pilot who thinks for sure his aircraft will be shot down because he forgot his lucky rabbits foot. I guess you could say that many superstitions are neurotic behaviour.
So this is one of the simpler ways we can bring on a self-induced mental illness. I hope this has been of some value to you. Just watch those thoughts because, as I've said to so many 'Mind matters most!'