isnt mashing anything in fighting games bad? your example doesnt really illustrate how mashing something in negative frames is a good idea?
It's only bad if you're being predictable with it. But this goes for everything, not just mashing.
An example of "dumb thing that works" that often comes up is people who wake up with crouching medium kick in SF instead of blocking or doing a wake up attack. You always hear Mike Ross complaining about it. Why would they do this? Surely any smart player would know that wake up cr.mk would lose to any meaty button you press or a meaty throw. So why wouldn't they block, tech or reversal instead? The reasoning for this example is that wake up cr.mk hits low. So if you are trying to bait a DP or make their throw attempt whiff, you will be walking backwards outside of their range. But if you are walking back that means you aren't blocking low. That's why cr.mk works in these situations. Even if it's the "dumbest" possible thing to do when you are waking up, it will work if they are trying to bait a throw or DP.
That's just an example of something dumb that can become the smartest of reads.
For mashing buttons, the reasoning is that in certain fighting games, you sometimes want to take advantage of your +frames to take a step forward and go for a throw or frame trap. This leaves a gap that allows your opponent to hit you first or trade. So if they often go for the cr.mp, walk up, cr.mp/throw mixup, you could eventually start mashing or reversal to avoid or punish their mixup attempt. Otherwise you'll always be sitting there guessing and taking all the pressure forever.
If you mash buttons/DPs here and there, then they might get more hesitant to frame trap you next time. Which increases the chances of being baited but also opens a window for you to reverse the pressure. e.g. Next time they won't press buttons and will just block to bait your DP. And you, instead of blocking or mashing DP like they expect you to, could decide to just walk up to them and get a free throw. Again, they'll think you're stupid because walking forward when you are -3 isn't very "smart". But it will still work against the best players.
Of course sometimes you'll see top players keep doing the same "mistakes" over and over again. Because at some point it becomes this yomi game of "I dare you to do it again" vs "Sure I'm not afraid of you". That's why it's harder to condition players who play at the highest level because some players absolutely refuse to respect you or refuse to let fear dictate their decisions. But as a player you also need to recognize these kinds of cocky players and take advantage of their arrogance. And that means you might need to mash buttons and throw random unsafe moves against players like Smug, Infiltration or PL.