Very strange problem during beginning with MKR Wifi 1010

This error occurs when some other application has the serial port of your Arduino board open. That can happen even if you have two instances of the Arduino IDE running and both are trying to use the serial port via Serial Monitor or uploading. In some rare cases, the operating system can leave the port stuck in an unusable state. Restarting the computer fixes that.

The sketch code won't cause this particular "Port busy" error. The sketch interfering with the upload process has a different symptom, such as the one you posted in reply #4

That may be true, but keep in mind that the firmware is the sketch you wrote.

Arduino boards and software are tools for people who want to create new things and learn and have fun overcoming the challenges of that creating and learning process. They are not for the people who want some pre-made consumer product. If you want something like that, then look elsewhere. If you want to have success with Arduino then you are going to need to adjust your attitude. Going into this mode of immediately jumping to blaming your tools on the first problem you encounter is not productive. It is possible there is a bug in the free open source libraries or toolchain, but far more likely is that there is a bug in your sketch. You'll never know which it is if you don't have the perseverance to complete the investigation.

You won't have this specific class of problem from the ESP32 due to it not having native USB capabilities, but you will surely have plenty other problems that are just as tricky.