As Grandpa stated; fired out of battery.
Before thinking the firearm malfunctioned, inspect it for grundge in chamber or ammo issues.
I actually had same issue with a 15-22 while my grand daughter was shooting.
First I cussed S&W. It was brand new firearm. Nobody was hurt, as all safety equipment was worn.
I totally agree with the shock of it all. The out of battery round was way louder !!!.
I thought son was screwing around and him the inverse!!! (I haven't a clue

).
After sitting on step{I'm rancher} we thought about what to do and decided to do some CSI. Checked the chamber and bore, all was fine.
Filled a 10 round mag and hung gun around a very large rock and fired 5 slow and 5 fast. No problem. Next possible problem was ammo. That evening I dug out my reloading measuring tools. I had some qualitve and Quanitive analysis in college. Turns out ammo had very serious quality issues. Canted bullets, out of round case heads etc. When anybody but me is shooting the only ammo used is CCI. In revolver or single shot it will work fine, but in semi auto it's best to find a different brand. usually only a couple issues per 100, but that's enough for your mentioned incident.
Just food for thought. Rimfire ammo should be checked before shooting. I use a go - no go die on all centerfire ammo. Once in a blue moon I will have a reload out of spec, it happens. Researching one for .22 now. Food for thought.
I got C's and C -'s in english, so take the rewrite with a grain of salt. LOL.