Some countries require a period of National Service, others have other regulations that come with living there, which are decided by the leaders in those countries, in some cases, after a plebiscite or similar process. And most countries restrict those that they allow in to become permanent residents.
Many of those same nations who are admonishing the US for restricting 'refugees' and other 'migrants' from coming here, have more restrictive regulations than the US. Mexico and the Vatican included.
So, while people may have the "right" to live anywhere they wish, the ability and opprotunity to exercise that right may be somewhat restricted.
Living in any country apart from the one you are born into is a privilege not a right. It is much like how one treats their home as no one has the right to just walk in and make themselves at home in your house without you granting them the privilege to do so first which you can also revoke at any time as it's your house and your rules as to who can live and can't live there and what they can or can't do(that doesn't conflict with any laws in the country you live in of course).