In ancient times people started to believe in god and gods to cope with things they couldn't understand. The mind sometimes refuses to believe in mystery, so they invented God to deal with the unexplainable. Today, that's not necessary anymore. It's a disorder and it's not God punishing you. I have a sibling who became a hardcore JW cause of a similar experience. His problem was panic attacks. He got one so bad that he felt he was gonna die. Heart beat raised and he was short of breath, then in desperation he screamed out "Jehovah!" and suddenly it went away. He started to believe in God ever since. He also had a severe asthma attack and same thing happened. He called out for God and passed out in the ambulance, waking up in the hospital later.
Disorders and near death experiences are not acts of God cause they happen even to the most holiest person you can think of. But anyway, you should definitely keep seeing a doctor. That sounds like a terrible experience to go through.