A theory is that a superstition is formed when a reward happens while an individual is doing an action. This is called classical conditioning and was made famous by Pavlov’s dogs, as well as Watson and Rayner’s Little Albert experiment. This can be applied to religion too - maybe something good happens to a person after they have prayed. This can condition the person to believe their prayers have been answered, especially if it happens more than once.
As previously discussed, the super-ego is is the moral component of the psyche, which makes a clear distinction between right and wrong, and makes no allowance for special circumstances. It is possible that an individual’s desire to follow religious rules about ethics stems from the super-ego’s need for morality.
Religion as a by-product of evolution
Freud’s suggested that our large brains, which evolved for other reasons, led to consciousness. The beginning of consciousness forced humans to deal with the concept of personal mortality. Religion may have been one solution to this problem. Other researchers have suggested psychological processes which may have also adapted for religion. Such mechanisms may include the ability to decide what is dangerous to us, the ability to come up with causal narratives for natural events (etiology), and the ability to recognize that other people have minds of their own with their own desires, beliefs and intentions. These three adaptations allow humans to explain things that could not be explained otherwise, e.g. thunder, lightning, movement of planets, complexity of life, etc.
Conformity is a type of social influence involving a change in belief or behavior in order to fit in with a group. It is the most common and pervasive form of social influence. It explains why children with religious parents are much more likely to be religious themselves. To reduce conflict, an individual will either comply (appear to agree), identify (are influenced by a role model), or internalize (accept a belief as their own).