Intense experiences will mess with you. I've had a similar thing happen, but unfortunately it went the other way. I found myself praying to "the probably nonexistent simulator 'god'" to make it unhappen. It wasn't that I secretly alieved it'd help, or had a "religious part" or anything like that. It's just that the reality was too damn horrible to accept, so my brain was desperately searching for solutions to make it all okay and going way down the search results. I never actually alieved it - It still felt completely hopeless. It's just that when the stakes are really high, you don't give up so easy.
Similarly, I don't think it's any religious part that's been in hiding in your head. It's just that you were anticipating a big loss, so when things turn out okay, you really appreciate it. It turned out okay when it "could have" turned out not okay, and you're thankful that it did.
It's expected and normal. Shrugging off a serious close call wouldn't be taking it seriously enough, and just saying "I should be more careful" before moving on won't make you more careful, so don't try to suppress it. Instead embrace the emotions that come up and sort things out until they're satisfied. Look in depth into the question of "could I have done something to prevent that?". When you've traveled far enough down the search tree that you feel satisfied and you've done what you need to do to be confident that you have actually taken what needs to be learned and applied it, then you won't feel conflicted anymore. I almost never come out of it without lessons learned, even when life hands me an impossible situation.
I'd also point out that since it's a common cultural script, it's very easy for your search tree to locate it. And for it to go "sure, you said you don't believe this, but 90% of the world does so it's worth at least a second thought!". And the "Pascal's Wager"-esque situation that praying to god to make it unhappen has a very, very low cost, and even praying in advance seems unlikely to be costly...
Well, I used to think that I do not believe in anything supernatural that affects what happens to me, but I'm wondering if maybe I actually do alieve in it. For example, a few days ago I had a close call in traffic, and when a collision I fully expected to happen just a second prior did not transpire, I mentally thanked... whom? I definitely had a clear feeling of gratitude for escaping, and I don't normally mean it literally when I say "Thank God!". So, who or what did I feel thankful to? I've never been religious, and I got rid of most of my superstitions over the years, but apparently there is still something there, and I do not know how to react to this knowledge.
What would be the proper reaction after a close call? Shrug and say "got lucky this time, should be more cautious next time"? What about when waiting for a diagnosis, what does sort-of-praying "please, please, let everything be OK" say about one's true beliefs? I know that I am much better at not blaming the world when something bad happens to me by chance than at not thanking the world when something good happens. Should it not be symmetric? Which part of a normally non-religious person wakes up and asserts itself in a crisis situation out of their control? Should it be embraced, suppressed, worked on?