Yea, when the AI realizes it's losing an invasion, they offer peace, but want your cities. Are they idiots? They should just offer straight peace, because then we're more likely to accept it.
Seriously....I know the developers are worried about the AI giving up too much. But STILL.
This is mostly based on military strength. Even if their invasion failed, if they have 3x your number of units, in their minds they are "winning" the war.
Also on a somewhat relevant note, as far as I can tell military strength is based merely on the number of units. So a warrior is worth the same as an infantry, when considering your army size.