Here is what I found as most satisfying ( https://www.reddit.com/r/totalwar/co...ge_calculated/ )to explain the damages :

I understand the Rome 1 system fairly well, and I think Medieval 2 uses the same system, but someone can correct me if it doesn't. Units have a certain amount of "lethal hits" they can take before being killed. This is referred to in game as hit points. Most units have only one hit point, but certain units like general's bodyguards, elephants, chariots, the general himself can have more.
The basic system for determining if a lethal hit is taken is: the attacking unit initiates an attacking animation. If they aren't knocked out of the animation and it connects, then the game checks the attacker's attack stat against the defender's defence stats. The defence stat is divided into armour, which is always applied; skill (or melee defence or something i don't remember the name) which applies only to melee attacks, not missiles; and shield, which applies to attacks from the front and left of the unit.
So your dude has 16 attack and is up against a dude with 20 (for example 10 armour, 5 skill, 5 shield) defence. He is attacking from the front with a melee weapon, so all three defence stats are applied. The game will generate a number from 1-16 for the attacker and 1-20 for the defender. If your unit is charging then their charge bonus is added to their attack for the first round. Also, if the attacker has an armour piercing (AP) weapon, they will ignore half of the opponent's armour rating.
If the attack succeeds, another number is generated. All attacks have a hidden "lethality" stat that is not displayed in game, that goes from 0 to 1. An attack with a lethality of 1 will "kill" on every successful hit. An attack with 0.5 lethality will "kill" on half of the successful hits. etc.
So your unit has to inflict a "lethal hit" before the other guy does, or if the unit has more hit points, inflict enough "lethal hits" to work through however much HP they have.
That's the basics. There are some more nuances, and of course things I don't understand, but this will get you pretty far.
So to summ up, the game randoms a number between 1 and the max Attack score VS a random between 1 and max Defence score (minored by the different factors like AP, side/back attack, weapon type). If attack wins, then the defender looses a HP or has chances to loose an HP (with that lethalty stuff).