It works like this
A signs a defensive pact with B
C declares war on A
B automatically declares war on C in defense of A
This can get screwy sometimes if you are already at war. They don't apply if you are already at war and as soon as you go to war they are canceled. So if you were at war previously when you signed it I am not sure if it goes into effect. It SHOULD, but I am not sure.
Best way to use them is to be at peace, sign them, and then wait for the eventual war declaration.