Both wanted land in Poland, but didn’t want to go to war with each other, yet. So, they signed a non-aggression pact, not an alliance, saying that neither would go to war with each other for ten years, nor would they assist anyone at war with the other. Of course, that lasted two years before Hitler decided that Stalin had to go.
The assassination of Franz Ferdinand is what started WW1, which was done by Serbian rebels, but the county was Austria-Hungary. The two nations that escalated the conflict was Russia, who supported Serbia, and Germany, who supported Austria.