They did not sign up for this deal, they voted against it. They are being forced to take foreign nationals because the southern EU states can't (won't) secure their borders.
They can leave the EU if they don't want the benefits of it anymore.
The reality of "securing borders" against these refugees would result in thousands of deaths. That's not a realistic solution to a problem, although Hungary probably wouldn't mind it.