Francis Bacon could not have been more insightful when he observed:
Today, we refer to this phenomenon as confirmation bias. Also known as confirmatory bias or verification bias, it is a tendency of people to favor information that confirms their beliefs or hypotheses. It works like this. A believer prays for the swift recovery of a friend. The friend recovers. The believer remembers this event as a divine "miracle," which is exactly in line with the believer's hypothesis: prayer is effectual.
The next friend isn't so lucky. The believer prays and the friend dies. Cognitive dissonance sets in and excuses are made. Perhaps it wasn't God's will. Maybe the dead friend had a mission to fullfil after death. The apparent failure of prayer being adequately explained, the believer pushes the event to the back of his mind and may even forget the event entirely. The event does not support the believer's hypothesis. After many such experiences with prayer, the believer will remember dozens of miracles in his lifetime and become unshaken in his faith in prayer.
A statistically significant percentage of diseases, including cancer, spontaneously improve, irrespective of the treatment. If the recovering friend drank Noni juice or wore magnets, superstitious people might likewise credit equally ineffective treatments for the "cure."
Science is not immune to confirmation bias. However, the scientific method focuses on disproving rather than proving theories. Peer review is an important safeguard. A scientist could make his or her career -- and win a Nobel prize -- by disproving the Theory of Relativity. No such checks or incentives to disprove a theory exist in the world of religion.