I had the exact same thing happen to me. Two Elk Birds got inside the fort (I managed to tunnel into the caverns unexpectedly) and ran around the place while my military ran around and around. I agree that it seems like the military pathing follows where the enemy was and not where it is. Case in point: an Elk Bird would run down a long 2-tile-wide hallway, hit the end and U-turn back up the other side. My military would pick up the chase from where they were stationed, run down the same hallway passing the Elk Bird running the other way until they reached the end and turned around. Likewise, if a bird ran into a large room and ran to the far wall and then took a 90 degree turn, rather than running diagonally towards it, a dwarf would enter the room, run to the far wall and then make a 90 degree turn.
This went on for some time. I couldn't set traps because my engineers would get scared away by the birds. I finally managed to corner the things in a room with a lockable door and station the military outside. Once everyone was present I unlocked the door, they filed in, then I locked them in there. They eventually killed the birds but it had already led to a Total Party Kill, I just didn't know it yet.
They had been kicking and beaking a lot of my dwarves while being chased, and interrupting everyone else, so I had a hospital full of injured, starving and dehydrated dwarves, since everyone would get interrupted trying to take care of them ... and then we had an ambush. Everything was in chaos from the stupid birds, half my military was in the hospital and a dozen goblin pikemen walked in and slaughtered everyone. It was especially sad watching them waltz into the hospital zone and splatter a bunch of helpless dwarves against the floors and walls.