The answer depends on the country. You appear to be in a country where this is a requirement. I am from a country where it is not. In The Netherlands, in national elections, anyone can vote anywhere as well.
It's quite simple: every voter gets a single voter card with their name on it. When they go to a polling station, they hand in their voting card (and show their ID) and get a different, anonymous card in return. Then they go and cast their ballot at this polling station. Anonymity is guaranteed because the voting card does not end up in the booth.
Note that in principle, whether or not someone voted at all is not guaranteed to be anonymous in this system, but it isn't either when a name is crossed on a list. I'm not sure if it's possible at all for this aspect to be anonymous, short of destroying all relevant information immediately after the elections.
An amusing side-effect of that in The Netherlands, some municipalities actually have a turnout of more than 100%. In the 2012 elections, the Dutch island of Schiermonnikoog had a turnout of 150.33%. How? Because the island has 761 inhabitants entitled to vote, but a grand total of 1144 voted on this touristic island. In practice, the liberty to vote in any place in the country means turnout figures are not very meaningful anymore except on a national basis.