The yelling is a mechanism for dramatising a moment in media. From an alternative standpoint, a yell (or
kiai) is a mechanism martial artists use to breathe out very quickly during the execution of a move. Much like how we exhale when lifting something heavy, the breathing is supposed to help our strength. I think that principle was carried over into media and was taken to a new level for making a scene more exciting/intense. In-universe, they're shouting because the moment calls for it
From a personal standpoint, the most noticeable example is from Setsuna F. Seiei from
Gundam 00, who more or less
always screams before finishing off a major opponent.