It's not like it's unprecedented for the UK to have a relationship with another nation wherein there is a defensive pact.
The UK basically has an offensive pact with the US in practice. If the US invades somewhere, the UK is part of that, either in logistics or direct support. At least, it seems that way. The "special relationship" and all that.

Anyone can argue this is a double-edged sword that increases relations with the US at the cost of other international ties. Pros and cons.

The same analysis would apply to the UK having a defensive (or any military agreement) with the greater EU (under the assumption that the EU has a standing military). There will be pros and cons, and where the people of the UK weight each of those is going to determine your cultural future.