The EU is not a state. It's a union of member states.
It can only act on either a majority vote of its member states or by consensus. (In practice 90% of EU decisions are taken by negotiation and consensus.)
If there were ever to be an allied EU army, which is highly unlikely, it would be subject to exactly the same kind of conditions as the Nato forces.
In any case, the British government determines UK defence policy, that is not going to change whether in the EU or out.