Through sheer, cold, brutal logic.
He’s excellent at compartmentalizing his emotions. Or suppressing them, whichever. He just kind of, forces himself to look at the numbers and analyze instead of feel. Which is his natural tendency anyway.
When there’s no amount of analyzing he can do that’ll help, he typically has to vent somehow. He’s been known to quietly stand up from a meeting, walk into another room, shut the door, let out a single, long, loud scream of frustration, and then return to his seat like nothing’s happened. Table-flipping is actually on the more extreme end of his emotional reactions, but it’s got something in common with how he vents in general: it’s abrupt, explosive, and brief. And then it’s over.
He doesn’t like venting by getting mad and getting violent; but it is, he’s found, an acceptable—encouraged—way to vent in the Autobots. And at least he’s only taking out his anger on his own vocal cords or walls or furniture instead of actual people. But now people have started mocking him for that too, so he doesn’t know what to think anymore. Yes, yes, he’s flipped a couple of tables. Ha ha, how funny, right? He flipped those tables because he actually wanted to flip you. But he didn’t flip you. Instead he just destroyed his own workspace. You’re welcome.
He has another alternative, when he can get some private time. If rationalizing his way out of his anger/fear/anxiety/whatever isn’t working, and if he’s not at the point of furniture-flinging fury yet, he finds somewhere to hide by himself—sometimes he just locks the door to his office, sometimes he hides in small spaces—and he plays with his magnets.
Focusing on the tactile sensation of the magnetic fields on his hands gives him something else to latch his big processor onto—calculating the shape of the field, calculating how two magnets’ fields interact with each other, how they tug on his armor, how they manipulate the flow of electricity in the wires in his hands… It eats up RAM that would have been otherwise spent on circling around and around whatever’s bothering him. (That’s how Prowl thinks of it—reallocating RAM, taking bytes from one task to another. He sees his world in numbers, and that extends to himself.) So when logic isn’t working, he hasn’t yet been pushed to rage, and he can get away from people for a while, that’s how he calms down.
Usually, he’ll never do that around other people. In an extremely rare (visible) show of insecurity, he’s self-consciousness about bringing his magnets out around other people. It takes up most of his mental capacity—like, that’s why he does it, to fill his mind—so when he’s playing with them he’ll just be sitting rigidly staring fixatedly at his hands while he plays with a little magnet, and… well, it looks dumb. It looks silly and weird. That’s how he feels, anyway. So he won’t do it around other people. If Prowl needs to calm down and he actually pulls out one of his magnets in front of you to play with, that’s means he’s extremely comfortable with you. … Either that, or you’re Tyran Jazz and you have magnets for hands and he’s willing to make an exception because wow magnet hands. Because of his shyness about his magnets, that’s only a calming down method he can use in private.