Not strictly true – many animals, particular those that are fast prey (gazzeles, mice etc) are programmed to flee instead of fight. Most prey in Africa for instance would only fight a fiersome predator like a lion in extreme cases, and likely lose!
Most animals have a ‘fight or flight’ response – that is an instinctive reaction in dangerous situations.
Obviously if you are two same species animals fighting for dominace in a group, running away is a bad strategy – those that flee will likely not get to mate and not get resoruces.
But prey species will run – if you run away you’ll be ostly unscathed – but if you stay and fight, even victory could result in injury and with no hospitals or doctors, something as simple as a broken leg could result in death.
We all have a fight or flight response, it depends on the species and what the perceived reason for the fight or flight response, if it is another animal invading their territory they are more likely to fight than flee. Predators are more likely to fight that prey animals, especially if a male is entering another males territory and there are females about.
Sometimes it is a judgement call for animals regarding whether they fight or run, my little dog ran across a field barking at an Alsatian and would not come back when I called, but when she got up close and saw the size of the other dog she just turned and ran straight back to me!