That's what would happen if this is done in some small market, like let's say Qatar. With large markets the situation is rather different, since it is so essential for the companies to sell in these markets. Do you think Apple would no longer sell iPhones because of the USB C law or right to repair laws?
Also, some of these laws are aimed at the externalities caused by these corporations, such as e-waste and computing disenfranchisement (well, at least partly). I am not generally supportive of governement regulation as solutions to our problems, but when the adversaries are as resourceful as Apple or Microsoft, the tradeoffs are different and we have no other way to realisticallt fix these issues.