After the Franco-Prussian War, why did Germany form alliances and start to build up its military?

After the Franco-Prussian War, why did Germany form alliances and start to build up its military?