Germany was allied with Austria-Hungary. Russia was allied with Serbia. The German government was afraid that because Austria-Hungary had attacked Serbia, Russia would attack Austria-Hungary to help Serbia. Because of this, Germany felt it had to help Austria-Hungary by attacking Russia first, before it could attack Austria-Hungary.