Hungary and Poland were the only member states to vote against the EU’s new migration and asylum agreement.