They know from pre-ballot polls, from comparing profiles of the age, wealth, birthplace and occupations of those living in a constituency with how many in each constituency voted for each party in a previous election, from the answers they got from all those phone calls and internet questionnaires we were bombarded with. It is a whole industry called demographics, and you can put into a search engine the word demographics and where you live and find out a whole lot of things about the area. Estate agents do that a lot to tell potential buyers what kind of place they are thinking of moving to. You can find out the voting history of your area online easily too. Try it and see.
They don't know from the ballot papers about individuals, Because the links between ballot papers and the numbers on them are sealed up, locked away to be kept for a year in case of accusations of fraud, then destroyed.
Here is the answer to the question 6 years ago:-
Q "If my ballot paper has a unique number how can my vote private? "
A " In UK elections, each ballot paper has a unique number which appears on the paper and its counterfoil, and your electoral register number is noted on the counterfoil in the book of ballot papers, so yes, in theory it can be determined how you voted. However, there are many other procedures prescribed in election rules to keep the ballot secret. When the polls close at 10 pm, the counterfoils are parcelled up into sealed packets. At the count, the papers, once unfolded, must be kept face up at all times so that nobody gets to look at the serial numbers printed on the back, and the count is closely supervised by the Returning Officer and his staff and representatives of the parties. When the count is complete, the ballot papers are likewise made up into packets and sealed. The papers and counterfoils are kept for 12 months in a secure place, then destroyed."
"^Thus there is no practical opportunity for anyone to work out how you voted. The reason for noting your register number on the counterfoil is to protect against electoral fraud. It enables electoral fraud to be investigated if any allegation is made of this, but even so, the sealed packets may only be opened by an order of an election court, which would only be made if the court felt it necessary for the specific allegation of fraud to be investigated - say if it was alleged that the ballot papers had been tampered with, or there has been widespread impersonation of voters affecting the accuracy of the result. This has not happened since 1911."^ The Dark Side · 6 years ago
uk.answers.yahoo.com/question/index?qid=20100421164020AAlOciN