If code was impossible to make safe banks would still be doing manual labour and ATMs would’ve been phased out.
Financial transactions are logged and the logs maintained for a certain number of years. You can definitely use a similar system for voting when the stakes are low - local elections, for example. But an electronic voting system cannot be both secret and verifiable. In practice you make finding out how someone voted as hard as possible, and hope that a future government will not put in the effort to crack your system. All of which is completely unnecessary when paper ballots exist, and can be both secret and verifiable.