People pray for two main reasons:
(1) When young they were taught too, same reason they eat with fork or chopsticks and do other learned behaviors (Shake hands or bow, etc.)
(2) Fear and hope that some greater power will help them, if asked in sincere pray. - Pascal's wager applies. I.e. what have you got to lose? Answer: zero. What have you got to gain: X, which may be non-zero.
Before my early teens, I prayed for reason (1), then I transformed into an agnostic, and it seemed of little use as even if some god(s) existed they obviously were not concerned with earthly events and certainly had no foresight. If they did, they could have let / caused Hitler to die of heart attack in his teens.
However, behavior patterns that once gave some comfort when under stress, are not forgotten. Once, more than four decades ago*, while sailing at night, I heard a "hissing" sound and looked up to where it seemed to be coming from. I immediately saw the bluish glow of "St. Elmo's fire" at the top of the aluminum mast. Instantly (as a physicist) I knew the boat was in an intense electric field and that it was so strong (amplified at the mast tip which was at same potential as the sea surface) that it was ionizing the air there.
I was already at the stern with hand on the wooden tiller so did not expect a lightning bolt to pass thru me, but thru the aluminum mast which was electrically connected to the metal keel; however as I was only a couple of meters from the mast, I feared the dB/dt could kill me. You can believe I was soon praying as sincerely as I ever did. Fortunately, the hissing stopped in a few minutes. The power of pray? I doubt it.
* Interestingly, intense fear makes for strong memories. I can still mentally see that St. Elmo's fire!