As far as I know, the European Union is
a political and economic union of 28 member states that are located primarily in Europe. The EU has developed an internal single market through a standardised system of laws that apply in all member states in those matters, and only those matters, where members have agreed to act as one. EU policies aim to ensure the free movement of people, goods, services and capital within the internal market
Moreover, according to this, Citizenship of the European Union
European Union citizens have the right to free movement, settlement and employment across the EU.
However, certain European Union countries such as Hungary, Poland, Czech Republic and Slovakia have opposed immigration and rejected asylum for refugees, and also the European Union through the European commission was trying to impose mandatory quotas of refugees for all of the countries.
My question is, if supposedly the European Union is a political union where its policies guarantee the free movement of people, how do countries such as Hungary, Poland , etc do to stop the flow of refugees to their own countries, and also, how is that the European commission have to treat this issue as a particular issue, if supposedly the foundation policies of the European Union itself guarantee this?