Letting off steam when the game is getting to you is a perfectly human response, and sometimes necessary to avoid internal combustion. However there may be a performance and learning cost if this becomes an unchecked and frequent behaviour. Self control is a key tool in the toolkit.
The cost of getting the hump
The most obvious and talked about cost of poor self control, is how easily it compromises the next shot because you are not in the right frame of mind. The second and more pertinent to learning is missing the learning window.
The learning window
In the seconds immediately after a shot, is a learning opportunity that tends to evaporate quickly. The feels in your body buzz around for 8-10 seconds then dissipate. They potentially offer clues to why the bad shot happened e.g. you sensed a loss of balance through impact). If your attention is distracted by damning self judgement and anger, you will be blind to these.
Where was my attention on that shot?
An even more subtle, but equally important observation that could explain the shot that just happened, was where your focus was in the swing. This is such a fleeting experience, that it's usually impossible to answer after this window closes.
Solving this problem
If you feel better self control would make you a better learner (and thus a better player) there are two things to consider - the micro and the macro.
Take a deep breath
Most efforts to solve this problem are around a specific action you can take to disrupt the natural response immediately after a shot. Taking a deep breath for example.
You may not need a strategy. One of the themes of my coaching is that good golfing behaviours tend to flow naturally if, upstream, learning is at the source. Developing a growth mindset promotes such an effective acceptance and response to failure, that bad shots don't have the same sting that they once did.
If this is the case, the natural response might gradually evolve from anger and confusion into a remarkably self-aware diagnosis of why the error occurred. This breeds a confidence that not only can you correct an error, you don't fear them either.