@Chrona You specifically asked about "why do you bother treating soldiers as opposed to letting them die in a ditch". The answer is that it lowers the morale of the soldiers.
Triage is a separate issue. If you've got two guys shot, and one has been shot in the heart and one has been shot in the gut, you try to save the one who's been shot in the gut, because the guy who's shot in the heart will almost certainly die. But if you've got only the guy who's been shot in the heart, you still try to save the guy shot in the heart. (Unless you're being shot at, in which case you should prioritise staying alive, obviously)
The reason not to actively hunt down and kill ENEMY medical staff is because then you open up the can of worms that is "killing noncombatants" and "total war".
Again, pragmatically, there's a big difference between case 1: "you deliberately choose to not treat your wounded" and case 2: "the enemy is trying to kill your medics".
The difference here is with case 1: if you don't treat your soldiers with at least SOME care, you will get many more people deserting, which moderately hurts your fighting capabilities.
With case 2: If the ENEMY tries to kill the medics, first off, you can lambast the enemy soundly for being jerks, and get MORE recruitment, not less. Second, you can then move the medical staff further from the front lines or support them more, forcing the enemy to overreach to try to kill the medics and bomb hospitals, and thus seriously deplete the enemy's attacking force for trying to shoot the healers first.
Lastly, if the enemy starts attacking noncombatants and medical staff, you then can use that in the propaganda war and also commit atrocities of your own, citing "they started it". If the rulers of a country trying to kill the enemy's medical staff have a big part of their country bombed to smithereens in retaliatory strikes, that's both a loss to their military force AND their economy. They too can respond in kind, but wars tend to be fought over resources, and if both countries exhaust themselves in a total war both countries lose out, and it's far more likely one side will sue for peace or sign a peace treaty before that.
Total war is very rare in the real world, because total war destroys the things you're trying to rule over - people and infrastructure. What's the point of doing total war if you lose a whole load of your own country's strength and gain back the bombed out shell of another country if you win, and you're completely wiped out if you lose? That's what bombing hospitals gets you - it's the tactic of people with nothing left to lose but their own lives, because escalating the fight to noncombatants and civilians will inevitably lead to YOUR noncombatants and civilians getting killed. Which is very, very unprofitable for everyone.
Most militaries aren't totally destroyed before one side sues for peace. When it's obvious one side has lost, they tend to surrender and agree on how much loot the winners get. It's relatively rare the winners say "we want to murder every single one of you", because they want money, not blood.