You've learned lots the hard way. Glad you got through it all. Mother Nature's a tough teacher, she gives the test first, and the lesson afterwards (that's not my own thought, I heard it somewhere).
As to me? First-ever night dive, 90 miles offshore. I had maybe 6 or 7 post-cert dives at the time. No buddy, it's a "group" dive i figured. At the gate, took my reg out to tell the DM my diver number for his checklist as required, then jumped in-----with reg still dangling out of my mouth ;-) Which reg then bounced up with the big splash and dislodged my mask. Not quite enough air in BC to float, so now I'm underwater, alone in the semi-dark, no reg or mask in place, mostly exhaled lungs and the next inhale would be the ocean..
Oooookaaay, this is not good thought I, but (very) fortunately my next thought wasn't panic, but: "Wait, didn't we cover this in class?" Yeah, we did. They said, "Just remember, if you can breathe, then you can solve all your other problems". Got it--I needed to breathe.
So I reached around back for a reg and swept my arm forward, came up with my alternate. What the hell, air is air, good enough. Had just enough lung left to clear the that hockey-puck reg. Wow, what a blessed inhale!! Air is wonderful stuff.
Then came my second recollection from class: "put mask back on, hold in the top only, exhale through nose, repeat repeat". Did that. WOW, did my eyes sting from the salt. But I knew that would subside, and now with empty mask I could breathe and (almost) see, through very watery eyes. Breathed and blinked a few times. Then, I swept my arm back again, and came up with the primary reg. Okay!! Clipped off the octo, added a little air to BC, surfaced.
My next rookie thought as I looked around-- God, I hope nobody saw me, this is embarrassing. Well, nobody did, and they were still jumping divers in nearby. My little misadventure seemed to take forever, but it probably wasn't more than a minute. Cool, my (undeserved) pride is safe. What to do now??? Well---it's a dive, bud, remember?? Oh, yeah. So I went along the guide line, down the mooring line, my watery eyes cleared, and I joined the crowd, who were making a light show out of Stetson Bank with our dive lights and colorful tank lights.
Lessons learned, the semi-hard way: get a buddy. put reg in mouth "before" you enter the water. Have more air in BC so you at least surface even if you go fetal or get preoccupied.
And the big lessons: Don't panic, just try to work the problem. And--The stuff they tell you in class is important. I was grateful for my (very good) instructor's voice in my head, instead of my own.