If you ever get an AI this good you can just resort to handicapping it or giving players bonuses

. It would be a top-tier training tool for PvP too.
I doubt this would still be true, however, if the AI were optimal or even kind-of close to optimal. Humans put up pretty drastically different times/outputs on the same start(s), compared to other humans. This suggests that there are mistakes being made routinely, and an opponent who makes significantly fewer will pull ahead quickly.
It is a bit more complicated than that. One of the reasons Machine Learning is rarely used for games is that is unpredictable. These systems work basically exploring a solution space to reach a goal by taking amy path they see fit but one the designer has no control over. Giving them restrictions or subgoals is posible but usually is not a good idea.
For example, you have no control on what units or buildings they will buy or not, they may decide that moving units is not their thing, build only a type of units, do not sign ever any alliance, they may decide to never set cities coast, or that they will never research some techs, or only try to build the same one or two wonders and found the same religion in every game. They will have to relearn the game for any rule change and so on. In the end it is still posible to use these systems. But to warranty that they behave in the way a player expects the AI to work, so many restrictions have to be imposed that the effort is not worth it.
Also these methods are very expensive to build, and they may still make some weird decissions that cannot be corrected with a patch, but may require to retrain the AI for months.
However the most obvious reason to not use them is because experience shows that players dont want them.
The most advanced AI systems ever used on official games are present in the Total War series, and their AI is seen as insanely bad in many iterations of the game. A very good AI can utterly fail, due to being unable to handle apparently very easy tasks. And when it works properly it can be a bigger dissaster cause it can be so good that the player isprevented to play the way he wants. So in almost all games perceived as having a very strong AI, the AI does not actually try to win the game, but instead tries to cheat to be perceived as competent while in reality is programmed to make the player have fun.
Lets see how a game with a great AI works. Lets start with a simple case like Doom 2016, enemies just have to try to kill the player and they seem to be very good at that. Seems simple, right?. Well it is not, the game cheats in insane ways to ensure the player has fun with the game. The enemies need to ask for permision to each other before attacking the player, in order to attack only one or two at a time, the enemies will aim worse if the player is moving, they are prevented to damage the player when he is in vulnerable positions ... and so on.
Usually games have a game director, that allows or dennies events from happening in order to not frustrate the player. In X-Com, the game cheats so if the enemy crits the player, their next shots will fail, or is ensured the player does a warrantee hit after missing high chance shots. Is spec Ops: The line, the enemies in addition to attend to a game director, are required to expose themselves out of cover, are prevented to be too accurate with grenades, and fake running low on anmunition. Ally NPCs in many games are often warranteed to kill and fake their attacks sending petitions on the enemy to die instead. In Starcraft II, the non official Deep Learning AI handicapps itself by using a smaller field of view than the player and limiting the number of actions per minute it can take, in Fear the game enemies cheat by speaking to the player to reveal their positions, in RTS games the AI often follows a script that is warranteed to give the players a chance, in turn based games the AI is often forced to make mistakes by taking ramdom actions, or has forbidden behabiors such as surrounding the player....
All in all, designing an AI for a game is difficult, and the goal is never to create an opponent that wants to win the game in the most efficient way possible. The goal is a much more difficult one, to create an opponent that creates commitment and challenge, but ultimately is designed to be beated.
Granted, the AI in civ is not good, but the problem is not what you think it is. To create an AI in civ that will beat the crap out of a player is not so hard. But if you think you want that, you are likely very mistaken. The devs have the task to create an AI that builds an empire, uses the game systems and acts like a human leader would act. That is a much harder task than making an AI that wins.