Alright, so after several messabouts with various save files, I've decided to call this the Dwarven Bystander Effect.
Based of my testing, I believe it's caused by too many dwarves in an area with enemies, which somehow wonks up the system that determines hostile targets and whatnot. Thus militia does not attack those presumed unhostile goblins; even when I turned my military dwarves back into civilians, they don't flee the goblins like normal citizens do (instead they amble casually away from the siege).
Of course I have no idea how this all actually works, but here are my results at attempting to defend Cloisteredtangles from the vile force of darkness. Over and over again.
Note: This begins at the point when the entire military is already standing in the middle of the siege and not attacking. Unfortunately I dont have a save where the goblins just arrived.
1) Stationed all military in the middle of the siege.- Problem persists.
Most goblins level up to elite status, and my legendary dwarves block and parry every blow - until they fall unconcious and get a spear driven through their skull, that is. The dwarves finally strike back when only 3 squads remain; altogether they total only 5 at this point.
2) Station military far away, AKA mission GTFOutofthere- Persists, minor improvement.
Most soldiers do not move to their new positions as they seem to automatically be drawn into melee situations, despite not doing anything when they reach the invaders. Eventually, enough soldiers die or move away that the remaining ones start fighting back.
3) Make most of military civilians by freeing their barracks and setting them to inactive, with one squad left in the middle of the siege.- Persists, minor improvement.
Same as above, even as civilians they seem to be drawn towards the melee. Considering that most civilians stayed in the midst of the siege, results same as 2.
4) Make ALL militia civilians, deactivate all civilian alerts. - PROFIT!
Oddly enough, when the alert is disabled, the civilian militia finally starts to
amble away from the siege. The random spread of the civilian militia manages to draw the invaders over a wide area. When they managed to spread out to a large enough area, two squads are activated, stationing them back to the now-dwarf-free siege site.
- Activated squads are now properly hostile to goblins (at least in relatively dwarf-free areas). They happily massacre goblins on their way to the station, and they continue the massacre at the siege site.
It seems that the best way to manage this bug is to just send small squads to battle. Unfortunately this means that your dwarves will be visibly outnumbered, so perhaps drawing the goblins out over an area would be a better choice beforehand.
So now you know