It can be done
One could easily design a system to be both anonymous and secure, using cryptographic certificates.
At the polling place you pick up a ballot, marked with a unique serial number that is signed by the body that prints the ballots.
You take this to an electoral official, who checks your id. They generate a document saying that you (elector X) picked up ballot form Y, and a random number Z. This document is then SHA hashed - we will call this "the hash". They store electronically a statement saying that You picked up a balot, the hashed code above, and this is signed by their code.
On the balot is then printed a barcode containing a message signed by the electoral official, indicating that some properly identified person was granted possession of the ballot. This mesage includes the hash. On the balot is also printed the random number that was included in the hash, but this is not done in a machine-readable way.
You then take this bit of paper to machine A, where you make your vote. Machine A prints on your balot paper a barcode ecapsulating your vote, the hash, and a signature by machine a. It also prints a human-readable vote mark.
You scrutinise this bit of paper. If your vote is recorded correctly, you take it to machine B. Machine B reads the barcode put there by machine A, checks the signature, asks you to confirm your vote, and if you agree, records the vote and prits on your ballot it's own signed certification that the vote was recorded. Machine B is run by an electoral official who is responsible for asking each person "does this balot show your vote". The machine reads the vote, shows the official the barcode that was read, and the official can check that the barcode read matches the barcode on the form.
OK. The electoral commision knows that you were issued with a proper ballot by a known official, but not which one it was. It also knows that some particular vote was recorded on each ballot, but not by whom, and that a known official witnessed that an elecor stated that the ballot contained their vote.
The ballot contains printed on it both facts, along with a random number.
You can then go to the website of the electoral commission, and check that the vote recorded for your ballot paper (which you have kept) is indeed the vote you put in.
If it isn't then it's possible to either determine that your vote has been tampered with or lost, or that you are lying.