Not sure if you're just playing "simple" here or not, but here is how a foreign government can influence voters/elections.
Taken from the linked article:
Russia’s plans to affect the U.S. election began in April of 2014 with the development of a “troll farm” that could spread false and disparaging messages on social media, as TIME previously reported and another crucial indictment confirmed. Mueller’s indictment in February of 2018 charged 13 Russian nationals and three Russian companies — including the Internet Research Agency — with conspiracy to defraud the United States, conspiracy to commit bank fraud and identity theft.
The Internet Research Agency and its employees, the indictment said, sought to conduct “information warfare against the United States of America” in order to spread distrust and support Trump’s election. In an operation that cost millions of dollars, the Russians studied U.S. political groups, traveled to gather intelligence in several states and developed a network of fake accounts that they used to infect the American electorate. Throughout 2016, they posted divisive content about topics such as Black Lives Matter, immigration and gun control; they bought political ads criticizing Clinton; and they pumped out hashtags like #Hillary4Prison and #TrumpTrain to their masses of followers.
All of this was incredibly successful, according to University of Pennsylvania professor Kathleen Hall Jamieson. Experts disagree about how to quantify the impact of Russia’s social media campaign, but Jamieson, who did a forensic analysis of online activity in 2016 for her book Cyberwar: How Russian Hackers and Trolls Helped Elect a President—What We Don’t, Can’t, and Do Know argues that it’s very likely Russia did sway the outcome of the 2016 election.
Beyond getting voters in the U.S. to follow Facebook or Twitter accounts and read fake news websites, the Russians translated their social media influence into real-life events. Posing as American grassroots activists, the trolls set up and promoted rallies in swing states like Florida and Pennsylvania, as well as at Trump properties in New York, according to the indictment. In one of their most notable moves, the Russian trolls hired a real American to dress as Clinton in a prison uniform at a rally in West Palm Beach.
https://time.com/5565991/russia-influence-2016-election/