in 1879 germany formed a dual alliance with austria-hungary which later , in 1882 , expanded to a triple alliance to include italy with the understanding to support each other if either countries were attacked by france or russia .