Walls give a 5% range bonus to defending troops when being attacked per wall level, also durability has to be overcome before the battle can be won. Attacks last 100 round and if you can't beat the defenses and wall durability in that time you lose the fight, even if the enemy has no wall defenses or army.