Stephen M. Walt. 1987. The Origins of Alliances. Ithaca: Cornell University Press. Chapter 2 (“Explaining Alliance Formation”), particularly pp. 17-40.
Alliances can respond to a threat by either balancing or bandwagoning. Whether states choose to bandwagon or balance depends on the aggressive states' aggregate power, geographic proximity, offensive powers, and intentions. Stronger states should have more tendencies to balance. Greater probabilities of allied support increase tendencies to balance. Unalterably aggressive states should provoke balancing. Nations should bandwagon with likely war-time victors. Security considerations take precedence over ideological ones and ideologically based alliances are unlikely to survive when more pragmatic interests intrude.