I imagine the following circumstances could perhaps play a part:
Genetic predisposition
Upbringing (not necessarily of a religious nature but might leave you more susceptible to religious thought from other sources)
Intellectual interests (some might be drawn to theology)
Personality (eg would a kind child be more drawn to certain aspects of Christianity?)
Existential despair
Trauma
Urge to belong
Urge to reject the status quo
Reaction to oppression (eg "in the next life things will be better")
Reinforcement of oppression, (eg "I am clearly meant to be at the top of society")
If you look at it just as a case of indoctrination, that alone wouldn't explain the varieties of ways people react to that indoctrination. Some people buy into it as adults, some modify the belief, some don't think all that much about it, some reject it completely, some discard one set of religious beliefs but take up another (eg imagine a girl raised in a Christian household who becomes a Wiccan in her late teens).
Then you have people who were not indoctrinated but become religious as adults.
Of course cultures will often dictate the nature of that religious belief.