You didn't know?
The EU has a security & defence policy, the ESDP. It's possible for members to opt out of it, but AFAIK only Denmark has done so, & Denmark is an observer member of the WEU, a western European collective defence agreement dating from before NATO was created, so involved through another route.
The WEU became dormant for many years, but was revived in the 1980s under EU auspices. Since 2000, its functions have been taken over by the EU under the ESDP , though the treaty remains in force. I'm not sure how the three non-EU associate members relate to the ESDP.
Basically, if NATO went away, the EU members & the European NATO members would all still have a mutual defence agreement.