Although history may at times seem to have the air of inevitably, it ultimately revolves around human choices. The world was trending against the US and its allies, with communism a powerful and going concern that might well have prevailed except for the election of Ronald Reagan in 1980. On that hinge history turned.
But there were big problems in Soviet Union. Their economy was failing. Their leaders refused to make reforms to their command economy. They were falling behind the West. Three Soviet leaders died in three years before Gorbachev.
Gorbachev knew he had to reform the Soviet economy if he wanted to compete with the West. That was where he made mistakes. It fall apart like the house of cards.