When you give your name and adressaddress to the polling station, they note the serial number of the ballot paper against your name and address and voter idID number, so it is possible to trace every single vote back to the voter who cast the vote.
In the case you suggest, they could simply notice that the same person has voted twice, find the votevoting slip that matches the record and mark it as void. This could be done by two seperateseparate people, one who knows the personsperson's name, address and voter ID, and they could pass the serial number against that name and adressaddress to a second person who could find the ballot paper and remove it from the count of votes. That second person would never need to know any personally identifiable information, and therefortherefore the secrecy of the vote is maintained.