Frankly, it is hard to tell with just your descriptions alone. Times like this a battle replay save for normal campaign games would come really handy.

Basically, one of the most important factors are how much of your men are killed during in a short amount of time.

In the latter case, it is quite natural to expect to rout. From the approach they are battered and torn apart by arrow fire, and when they reach the gates firey oil splashes down. Basically your units are sent in to a march of death.

In the former case, surrounding a unit is often not what it seems to be. You may have surrounded an enemy unit, but even during such a fight the actual numbers of soldiers fighting are pretty small. Surrounding a unit is usually expected to win because one figures that even heavy casualties are sustained, ultimately the surrounded band will wear down first. However, if the surrounded units are so powerful that they disrupt that logic, then basically no matter how much people you put into it merely means you throw more meat into the grinder. The meat will soon figure that its better to just run away, than get caught in the grinder. The battle of Thermopylae comes into mind.

There are much more factors in work, and sometimes an overwhelming force may not cut it. Thus, again, its hard to tell just what happened with your words alone, but the chances are that nothing actually may be wrong.