Most likely sometime in your childhood you were made to feel that feeling upset is not OK: you may have been shamed or even punished for it (even if it was in a form of withdrawal of affection). That means that you have developed a self-protective coping strategy to attack yourself first, before other people attacked you.
This may have served you in the past, but now it is probably became an automatic habit that doesn’t serve you anymore.
The way to deal with it is to learn to tolerate feeling of “upset”, which is an uncomfortable process because it requires you to sit with that emotion.
But I believe that it is possible to change this habit.
Awareness is the first step, validation is another, self-acceptance is the next and like that - you will be able to move on in the direction of being OK with what you feeling consciously and sub-consciously and this automatic reaction will dissipate.