I am confused.

There were many treaties that were invoked in July and August 1914 leading to war for four years.

In 1939, it was Hitler's unjustified invasion of Poland after Britain had guaranteed Poland's sovereignty that lead to the state of war between the United Kingdom and the Third Reich.  Canada declared war on Germany one week later, notably after the Montreal-bound liner Athenia was torpedoed.

Interestingly,  Germany declared war on the United States in December 1941, not the other way around.