I try to avoid making any suggestions to folks unless I can be alongside them when they're experiencing something they consider a problem and I can try to see what's happening myself.
There was this time I was helping teach a class for some CCW folks and working with them on a range. There was this one older right-handed gent who was experiencing his magazine dropping from of his PPK/s at least once every mag load. He appeared to be taking it in stride, but I felt it was potentially problematic in a dedicated defensive gun and asked him about it. He said he'd owned the gun for many years and that it had always had that 'problem'. The mag catch felt normally tensioned and exhibited good movement when I checked it.
I stood alongside him for a bit and watched his hands during some firing. Before he fired the gun the mag catch button wasn't being touched by a finger or thumb, although he was one of those folks who, for whatever reason, used a crossed thumbs grip.
When he fired the gun, however, and the gun whipped back and down, his left thumb tightened and appeared to push inward ... just as his thumbs were lazily following the rise and whip of the gun in his hands ... and his thumb perfectly shifted to reach the mag catch button ... and depressed it. The mag fell free of the gun. When the recoil impulse was finished his hands (and thumbs) realigned themselves where they'd originally been positioned, meaning away from the mag catch. Weirdest thing I'd seen for a while.
I pulled the fellow off to the side and explained what I'd seen and suggested he change his thumb position. He did ... and for the rest of the course-of-fire his chronic 'problem' of many year's duration was suddenly gone. He expressed himself quite well, and animatedly, when it came to figuratively kicking himself for not having realized the actual cause of the problem years ago and correcting his grip to accommodate the little gun he liked so much.
My point? The side, shape and configuration of some guns might not lend themselves as well to some folks when it comes to hand size & finger reach ... or how some folks have accustomed themselves to holding a handgun.
It might be as easy as calling S&W and getting a new mag catch button (if your gun is old enough to have one of the early mag catches, and that's actually the problem). I couldn't venture a guess unless I could handle and examine your gun & mag catch.
It might be something that can be addressed by changing your thumb position a bit. Dunno. I'm not there to see it firsthand, and see how your thumb & fingers may be tightening and moving during recoil.
If it were your thumb's position, and thumb tension related to gripping the gun during recoil, you wouldn't be the first person to have discovered a particular pistol platform/model which had the mag catch button positioned, in relation to your hand and grip style, where it became disadvantageous during live-fire.