The answer is: Hungary is forced to act according to EU law and Germany refuses to apply an optional clause that would suspend this law.
The explanation in detail: To understand what is going on in Hungary, one needs to understand the Dublin Regulation.
The Dublin Regulation determines the Member State responsible for an asylum claim. It consists of two parts:
- The responsible Member State will be the state through which the asylum seeker first entered the EU.
- Asylum seekers entering another Member State can be transfered back to the responsible Member State.
The consequence of the Dublin Regulation is that non-responsible Member States like Germany refuse to process asylum applications from most refugees and legally transferred them back to the responsible Member States. As a result of this practice, structurally weaker and poorer Member States like Greece, Italy, and Hungary have been left alone with the burden of the increasing refugee influx for many years.
It is not surprising that the Dublin Regulation was primarily supported and enforced by Germany. The Dublin Regulation was extended to the Dublin II and then to the Dublin III Regulation.
According to the Dublin III Regulation and other EU law, the responsible Member State has to operate reception camps, where they assess personal characteristics of the refugees (e.g. fingerprints) and where refugees have to apply for asylum.
Responsible Member States violate EU law if they allow refugees to pass through to another Member States without assessing and submitting their personal characteristics into the European Data Directory. Such violation of EU law entail a contractual penalty.
Thus, Hungary is forced by EU law to first register refugees in reception camps. Refugees at the Keleti train station in Budapest can shout "Germany" as loud as they want, Hungary is not allowed to let them go without concession of Germany. The Dublin III regulation includes a sovereignty clause that allows any Member State to declare responsible for the refugees. Since Germany refuses to apply the sovereignty clause, refugees can't pass through.