If you go to the "Who we are" page of the Union for the Mediterranean, you'll see that the purpose of the union is explicitly to bring the EU in contact with the non-EU states surrounding the Mediterranean:
The Union for the Mediterranean (UfM) is an intergovernmental Euro-Mediterranean organisation which brings together all countries of the European Union and 15 countries of the Southern and Eastern Mediterranean.
Because of its geographical composition, institutional governance and working methodology, the UfM is the ideal organisation for taking into account the priorities of both the EU – as reflected in the reviewed ENP and the Global Strategy on Foreign and Security Policy – and the Southern and Eastern Mediterranean countries.
There are historical reasons for this structure: The precursor of the current UfM was the Euro-Mediterranean Partnership, which was, at its heart, an EU-led initiative to improve relations between the EU and its Mediterranean neighborhood. As described in the Barcelona Declaration of 1995, the EU members and the EU institutions as well as the non-EU Mediterranean signatories agreed
to establish a comprehensive partnership among the participants [sic] the EuroMediterranean partnership through strengthened political dialogue on a regular basis, the development of economic and financial cooperation and greater emphasis on the social, cultural and human dimension, these being the three aspects of the EuroMediterranean partnership.
Over time, this partnership has turned into the Union for the Mediterranean.
So, to summarize: The UfM was always, right from its inception, intended to be an organization that comprises of all EU members and as many non-EU Mediterranean states as possible. It was never intended to be an organization that existed in parallel to the EU. Excluding EU members that are not bordering the Mediterranean would work against the stated purpose of the organization.