I really don't understand why anyone would pull the slide back, drop the mag, and then pull the trigger, all in that order. It doesn't make any sense.
It's about familiarity & routine. I shoot every week, and I teach gun safety. While muzzle control has always been a constant, thank goodness, the remaining rules get lost for a number of reasons. Being exhausted, over-familiar, distracted, (like the OP on the computer; doing two things at once), it can happen. I vaporized a lamp 15 years ago w/ a Glock @ 2am. Couldn't sleep, shouldn't have picked it up half-awake.
This ND is one of the primary reasons I have started teaching gun safety to student groups when I have opportunity (we participate in a home-school co-op). Precisely because IT CAN HAPPEN TO ANYONE. The 10-14 year old's in my classes nearly ALWAYS tell me my instructor's pistol is unloaded when the magazine is removed, then I get to see their wide-eyes when I shuck that snap-cap onto the table.
Glock has a serious problem with a design that requires pulling the trigger for disassembly. The OP is not the first to post an ND w/ a Glock. There are several in this thread alone, now to include mine.
They are great weapons, I own them, but they assume a mindset that flawed human beings do not necessarily have 100% of the time, and as this thread shows, that is all it takes.