The EU has made a deal, investing massive amounts of money into North African countries to keep refugees from crossing the sea. The EU representatives negotiating the deal knew exactly what was going on, even before the deal was happening.
There's no easy solution to the mass immigration problem, but this "solution" makes things worse for everyone.