I understand the main purpose of the EU was to prevent future wars between UK/France/Germany by binding them together. Unfortunately, that vision came at a time before they were considering existential threats from the middle east and Asia.
That’s their stated goal. The real goal was to be a “third power” in between the US and the USSR, and that has not changed even in spite of the new “identity” of the USSR (currently being called the “Eurasian Union”). The history of Europe typically shows wars ensuing rather than peace when its countries unite.
As for the Middle East, consider their policies back in the 60s and 70s, when they went under different names (such as European Coal and Steel Community and European Economic Community). They have historically been anti-Israel and aiding the revanchism of Islam.