On walls all units lose stamina much slower. Especially the defending ones. I suppose it has something to do with the low amount of soldiers actually fighting. The unit seems to have one pool of stamina for all soldier and as long as only a little amount of them are fighting or moving they lose low to no stamina maybe even recover.