There are four kinds of bonuses that can be applied to your army:
Generally, Great Buildings as well as special buildings and boosts are able to grant you these bonuses. Some Great Buildings may only affect your defending army (i.e. Deal Castle) while others only affect your attacking army (i.e. Zeus)! Keep in mind that they're always percentual, which means that they're not absolute bonuses but are calculated on top of the base values of your units.
As an example, let's assume you have an archer with 15 attack and 20 defense, as well as an attack bonus of 20% and a defense bonus of 30% for your attacking army. You now attack another player who has a marksman with 20 attack and 30 defense as well as a bonus of 4% on his city defense.
After the bonuses have been applied, your archer is now fighting with 18 attack and 26 defense. The marksman of your enemy is still fighting with 20 attack but 31 defense. As a result, despite having higher bonuses, your archer is most likely going to lose this encounter.