Why is it not the same in politics?
Most defense-related jobs [even relatively low-level ones] have much stricter nationality and loyalty requirements than that of a random CEO.
The president or PM is often the head of the armed forces in some way, so there's that issue if one were holding them to a much looser standard in that regard.
Is (or has) there any country where a foreign citizen can become Prime Minister or President?
There are examples of PMs being dual nationals (or former dual nationals). Iraq perhaps had a record of these recently:
Outgoing premier Adel Abdel Mahdi [PM 2018-2020] holds French citizenship and former prime minister Haider Al-Abadi [PM 2014-2018] is also a British national.
Not mentioned in that 2020 piece but the president of Iraq 2018-2022, Barham Salih, also held British citizenship, according to Wikipedia.
(FWTW, there was a Baathist era law 46/1963 forbidding dual citizenship altogether [art. 11], but his was abrogated after Saddam's ousting.)
As for someone not being a citizen of the country in question at all, that's a much tougher proposition, and I'm not sure I can come with examples.
But for minister jobs below PM, perhaps this is an interesting [enough] example from 2014...
In an unusual development, three foreigners were appointed to Ukraine's new government this week.
US-born Natalie Jaresko became finance minister, Lithuania's Aivaras Abromavicius economy minister and Aleksandre Kvitashvili - from Georgia - health minister. Hours before the vote in the parliament that installed them, all three were granted Ukrainian citizenship by President Petro Poroshenko.
The move is part of a fresh anti-corruption drive in Kiev. Politicians and other officials supportive of the idea say outsiders in the cabinet will have fewer vested interests, or links to local lobbyists. President Poroshenko also said Ukraine should make use of "the best international experience".
So at least the motivation in this case appears to have been along the lines you asked. (The [loyalty] issue that I mentioned earlier did come up in [pro-Russian] opposition discourse rather quickly; there are some quotes to that effect in the article that I won't add here as being rather predictable in their contents.)
I'm not sure there are any longer-term trackers on such issues, but Papua New Guinea had some 17 naturalized citizens become ministers. Most (13) were from Australia. There average per-cabinet was also relatively high (4) according to that blog's calculations.