Different countries use different means to ensure everybody and their dog don't just turn up and use their services (such as hospitals, schools or pensions).
Some countries – such as the UK – prefer to control the border but then have very few checks on the inside.
Other countries – such as many other EU countries – prefer to have an ID card of some sort that documents that the holder is entitled to access services.
And finally some countries – mainly Scandinavian ones, I believe – have a central database that keeps track of who can do what.
Of course most countries use a combination of these factors – for instance, when you use the Scottish NHS, they ask you for some personal details so that they can find your CHI number, which is the Scandinavian approach.
The UK approach is really nice once you're on the inside, because you don't need to carry any ID and in general don't need to prove who you are all the time. The problem with it is that it depends on controlling the border, which just isn't very easy these days. After all, any person who arrives legally – as a tourist, student or business person – can become an illegal immigrant simply by overstaying their visa. It also makes it almost impossible to have different immigration policies in different parts of the country (such as making it easier to move to Scotland than to England).
The other two approaches work much better in the modern world because being in the country doesn't entitle you to anything per se. If you don't have an ID card or a database identification number, you won't be able to access non-emergency health care, sign your kids up for school, or do any of the many other tasks you do as a resident.
Schengen, the EU's passport-free zone, to some extent depends on members using ID cards or databases so that gaining access to a country doesn't entitle people to anything. And one might argue that this is also the basis for the EU's free movement of people. For instance, Denmark knows exactly how many EU citizens have moved there and when, because they have to register for a database identification number as soon as they move there, so there isn't the same feeling that the government isn't in control of immigration.
It was thus quite interesting how the Leave campaign was so obsessed with controlling the borders. Unless they want to make it illegal to be a tourist, people will arrive, and some won't leave again, even though they were supposed to. And of course maintaining the open border with EU member Ireland will make it impossible to keep out EU citizens (because they can at all times travel legally to Ireland).
The lack of ID cards or a database is also what is making life so difficult for EU citizens in the UK post-Brexit. It's difficult to prove how long we've been here, and whether we actually ever ticked the boxes for being a legal resident. In many other countries, it would be an administrative piece of cake to find everybody who had been here legally for more than five years and send them a permanent residence permit, without any need for 80-page forms.
Much as I love the lack of ID cards and database identification numbers in Scotland and the rUK, I'm starting to think that what the Leave voters really wanted was a national ID card and/or a universal database, because that's the only thing that would make it harder to be an illegal immigrant here.
Of course Theresa May's solution works, too – namely to make the UK so unattractive and despised abroad, with a basket-case economy, that nobody in their right mind wants to move here. If she succeeds, immigrations numbers will fall below zero without any need for border controls, ID cards or databases. What a victory!