Burrows don't actually restrict movement, just tasks. If, for example, you have a burrow consisting of two un-connected rectangles, then dwarves assigned to that burrow can still walk freely in the non-burrow'd tiles between the two rectangles. They just can't accept tasks that have items/targets outside their burrow. The practical side of this is that for large burrows a dwarf usually stays within the burrow itself, but that's not always the case.
My guess is that you set your citizens on alert, restricting them to your "panic" burrow. The dwarves who were still outside didn't immediately move inside, and instead waited until they got a task that was within the burrow. They tried to walk inside, saw the trolls, and the task was interrupted. They proceeded to run around like idiots, constantly accepting tasks and canceling them, getting nowhere in the meantime. Same thing happens to me with seiges. The gatherers/woodcutters always seem to hang around outside more than they should when I set them on alert.
You might think about having all your surface dwarves (hunters, woodcutters, etc.) assigned to military squads, with no required uniforms and no scheduled orders, then set them to inactive duty. Then when disaster strikes you can activate them and order them to move into the fort directly, with the added bonus that they won't go skittering away at the sight of a single raven or some such.
EDIT: Ninja'd. Balls.