The Roman Catholic Church has a longstanding teaching, drawn from natural law, that the nation is an extension of the human family.
As the father of a family has not only the right but also the duty to protect those in his charge, the properly constituted authorities of a state have a duty to use their power to advance the common good of the nation.
“Political authorities, for the sake of the common good for which they are responsible, may make the exercise of the right to immigrate subject to various juridical conditions, especially with regard to the immigrants’ duties toward their country of adoption. Immigrants are obliged to respect with gratitude the material and spiritual heritage of the country that receives them, to obey its laws, and to assist in carrying civic burdens — The Catechism of the Catholic Church #2241
The mistaken idea that the RCC supports unrestricted immigration stems from its teaching on the personal right of migration. This teaching says that someone in straitened circumstances should be allowed to leave his country of origin, bringing with him those under his care. However, it does not include the unlimited right of migrants to settle wherever they wish.
“The more prosperous nations are obliged, to the extent they are able, to welcome the foreigner in search of the security and the means of livelihood which he cannot find in his country of origin.” — The Catechism of the Catholic Church #2241 BOLD added
The key phrase is “to the extent they are able.” The authorities of the receiving country have a primary duty to act in the common good of their own citizens, because each country, as Pope Francis said, has the “right to control its borders.”