Computers Cannot Actually Do Two Things
Your computer never truly runs multiple programs at the same time. Instead, it performs a high-speed illusion by rapidly switching its attention between tasks so fast that it seems concurrent.
This process is called context switching, where the processor pauses one task, saves its current status, and jumps to another. These switches happen thousands of times per second, making human perception unable to detect the gaps. While modern processors have multiple cores to handle some parallel work, the core concept of multitasking is mostly a clever trick to maximize hardware efficiency. It is essentially a digital version of a juggler tossing several balls, though only one is ever held at any given moment.
Source: Computer multitasking