This is for the new players......
As previously mentioned the number of units in att/def is 3*allies. To simply see the actual number you can go into profile and push the 'i' button.
It's worth noting that attack and defense are calculated independently. So attack is calculated (assume 33 allies or 100 units) as the top 100 attack on all units, the top 100 attack all weapons and the top 100 attack all armor. Where defense is calculated the top 100 def for all those things. Then there are also the upgrade buildings and defensive buildings which add again.
Where problems arise can be where you purchase an expensive defensive unit. But it's attack is high enough so that it's still included in attack as well and you lose it. That's why you should look at you units as two teams. One for attack and one for defense. For example the battering ram is excellent for protecting expensive defensive units because its cheap at 110g and has 8 attack.