It is anxiety related. It was for me anyway!
It stilll comes and goes but overall it’s reduced a lot since I discovered it was related to the stress in my life and my overthinking about it before I would go to bed.
It’s just like you describe sort of like forgetting to breathe just as you are falling asleep and you wake up feeling like you need to catch your breath.
You are safe and once you fall asleep your breathing will ultimately regulate.
As a second suggestion, try a round of stomach acid reducing medicine like a proton pump inhibitor (omeprazol) for a couple weeks.
If you notice a big improvement then GERD or silent reflux could be an issue.
Those are a couple things I discovered on my journey to getting better after a decade of this problem!
I have the exact same issue and I have had it for several years. After years of trying to figure out what the problem is I finally narrowed it down to sleep onset apnea.
Honestly, after dealing with this almost every night since May 2010, I had a 4 month period this last year where everything was totally fine and I slept like a log all night. No issues! I thought I was cured. Then it came back.
I had just gotten married and had an amazing honeymoon. My prospects were all lined up for my future and I hadn’t a worry in the world. That’s when it went away. “Coincidentally” it came back (seemingly to stay) once things started to get a little rocky with school and finances again.
Still trying to get back to that mental state to see if that was a key but it’s been tough and I’ve been having trouble Again for a few months. There are some placebo things that seem to help for like a week then stop working randomly, adding to my theory that this is all stress/anxiety related.
I thought for awhile the issue might’ve been from Silent Reflux as treating myself for that seemed to help wonderfully with my breathing issues but it stopped helping before long and I’m back to thinking it’s all mental!