The reason we say "don't be upset" is often because we don't want to have our emotions synchronized and be upset.
Podcast: Lisa Feldman Barrett: Balancing the Brain Budget [The Knowledge Project Ep. #92]
If we're getting along with each other, or even just around each other for a little bit of time, our biological signals will start to synchronize. Our heart rates and our breathing will synchronize. It's called emotional contagion.
Human nervous systems regulate each other. We're social animals and we evolved to have lots of ways to affect the nervous systems of another person. A lot of time when we say "don't be sad, don't be angry" to our friends, what we're saying is "I don't want to deal with you being angry or sad, and I don't want to feel that way so I want you to calm down".
Therefore, it’s really hard to sit with someone else’s distress and just let them be distressed. We will want to help them regulate because we want to help ourselves regulate. We don't want them to be upset because we don't want to be upset. It's not a completely selfish act, it's just that one part of the mechanism for us to have empathy.