It depends on how high magic the world is. IME in your standard D&D world magic tends to be somewhat isolated, you might have magic academies around but you'll mostly have a couple of low level mages a city. In that case any attempted tampering is unlikely to be off a scale to affect elections, unless your city happens to be the one with the country's magic school.

For initial discussion I will ignore divinations, as that's a whole mess of stuff not directly related to influencing the way others vote.

Assuming a more magical world, say one magical academy every few cities instead of one per country, then the question becomes one of how entwined the mages are with normal society. Are we talking about something like the Prince of Nothing trilogy (although I hear not the later books), where magical schools are relatively seperate, or something more like the Forgotten Realms where magic often appears in everyday life. In the former more effort is probably given to keeping the academies out of elections as a whole, although you still have the problem of unaligned mages, and other countries using their mages to influence elections. The more involved mages are the closer we get to the idea of permanenced Anti-Magic Fields covering polling stations.

But all of this has been assuming a relatively modern democracy, where everybody over the age of majority gets a vote. We can also lessen the danger by restricting the vote (somewhat counter-intuitively, because it means less people need to be influenced). If we assume that items that protect against illusions and enchantment are common enough to be bought than ownership of such an item or a certain level of income might be a prerequisite for voting (similar to how land ownership used to be a prerequisite). Although unless said restriction directly increases access to anti-tamper magic among the voting population it just becomes easier to deal with.

Which brings me to my final point. To pull this off you either need to have a high level custom enchantment/illusion spell to effect enough people, probably one designed specifically for this purpose, or a large number of mages to effect enough people with low level spells. If you have enough of the latter to influence the election why aren't you taking over the country more directly? Assassinate the government, mind control the heads of military long enough to consolidate power, replace people in positions of power with people favourable to you ASAP, maybe install a puppet head of state instead of being it yourself. You have hundreds to thousands of mages at your disposal, you could have mind controlled the existing parliament months ago. If you can do the former, do you really care about who's in power unless they're trying to interfere with your tax haven demiplane?