Several factors can contribute to the “fight to the death” mentality seen by some PCs. Often more than 1 factor contribute to the PCs not retreating in a situation. Broadly some of these are:
Game Mechanics: There is no good/viable/easy way to retreat in the rules. If my speed is not faster than my opponent’s than by the rules, I can never get away from them. Also, the AoO rules work against retreating. If I move away from my opponent, they get a free attack on me. If I use “disengage” to move away, then they can just move and attack me on their turn. I’m better staying and fighting then letting them get ‘free’ attacks on me.
Hit Points: I’m just as effective at 1hp as 100hp, why retreat.
Target Fixation: We become so fixated on ‘winning’ the fight we can lose track of our own status. I know this happens to me sometimes during on-line play. Suddenly I’m at 3hp without realizing it’s happened.
Mob Mentality: If everybody else is attacking then I should attack also. In the end nobody called for the retreat that was needed.
Gambler’s reasoning: If I’ve just had bad dice, and the DM has had good dice, that will even out soon. I just need to stick it out.
“Do, or do not, there is no try” or “We’re suppose to be heroes”. Running away just doesn’t feel heroic. If we’re playing a game to be heroes, then retreat isn’t (usually) something we think about heroes doing.
Linearity: Most fights do not occur all alone. Most are part of a series of encounters. We can fall into the thinking of this is fight “A”, I must get through this fight in order to get to “B” then “C” etc. in order to accomplish the goal.
It’s a Game, not a story: D&D is a game played my multiple people. A story is told by a (usually) single author. One can tell a great story from a game. But if one tries to turn a game into a story, problems usually result.
Past Experience: If in past games no PC ever really died. Then this fight should be no different and the incentive is to fight on. Conversely, If in the past the average was at least 1 PC death per session, and by the end of the campaign no original PC was left alive, then death is just an expected part of the game and there’s no reason not to fight to the death because death is expected.