Modern operating systems can run multiple programs at one time. Those operating systems are using an operation call context switching to manage to run multiple programs at once.
Would you like to learn how context switching happens in the operating system? Read this article. I have explained in a very simple manner how context switching happens in a modern operating system.