Some rules reference:
4a. All token conflicts are resolved before all city
attacks are resolved. It is preferable to resolve
all token conflicts simultaneously. Any possible
unsuccessful city attacks are not considered
token conflict and these tokens are only removed
during the resolution of city attacks. Any
foreseen surplus population may not be removed
during the Conflict-phase.
4b. Only after all token conflicts have been resolved,
all city attacks must be resolved one at a time,
in A.S.T.-ranking order of the defending players.
For each city attack, first define whether the attack is
successful or not. By default, an attack is successful if
the attacker has at least 7 tokens in the area containing
the enemy city. In the case of an unsuccessful attack,
all tokens from the attacking player in the city area are
If I understand this, first there is a conflict of tokens within a space. If after that conflict there are at least 7 tokens then the city is replaced by 6 tokens and the attack is "successful": the conflict with the 6 tokens from the defender and 7+ attacker tokens is resolved. The attacker would be rewarded a card even if there are 6 defending tokens after combat or the city could be rebuilt with Architecture.
Advanced military would only be beneficial to defending a city (preventing loss of a card) if there were already tokens on the city space so as to cause token conflict before city conflict. This might reduce the number of attacking tokens below 7 thereby causing the city attack to fail.