Since not many chimed in, I'll throw my 2c in.
I've been in competitive sports most of my life, and have had a few relatives who reached the higher ranks in some sports (Baseball, Archery, Figure Skating). Growing up and talking to those people, or being coached by them, one thing every single one of them told me, verbatim, is this - "Short memory".
This doesn't mean forget your mistakes. It means forget them until the match / game is over. When you're practicing is the time to think about all the mistakes and screw ups you've made, and then how to not do those. During a game the only thing you should be focused on is what comes next. Not how bad you shot the last ball, not how good of a leave you left your opponent, not I am going to look stupid if I lose. Your sole focus should be "What am I going to do if I get back to the table again". This works insanely well for me, and has for pretty much most of my life.
Does this mean I don't get frustrated or upset in the moment? No.. But it means I can most of the time realize it's about to happen before it spirals, and I can reign it in and get back to the task at hand, trying to win.
After the match / game is over, that's when I beat myself up over the dumb things I did. Then I go practice those things so I am not making the same mistakes over and over.