Rule #1 Do not expect too much from AI.
It's not even really AI, just game rules.
Somewhere in the code there is a section for what happens when War is Declared. What's missing in there is an If statement. If you get declared war upon, then all your allies go to war as well. Then it's up to the War AI to prioritize making military units, make battle plans, etc etc etc, one would hope.