Consider it this way: Your iPhone is a computer on a smaller scale. It works similarly to a computer. Your iPhone X, like a computer, is powered by a processor known as the A11 Bionic chip as its fundamental component.
Each time you use taps and screen touches to enter commands, the CPU is given a task to complete. As a result, the busier the processor becomes, the more commands you enter. This is the primary cause of the processor (CPU) overheating. When you push the CPU as far as it can go, it becomes fatigued and overheats. This is what happens when you don't take a break from your iPhone for several hours. However, even if your gadget isn't used frequently, this might happen. There are a lot of apps on your iPhone. There's a potential that if one of these programs turns rogue, it'll be active and operating in the background. If other programs have gone rogue and caused the CPU to work and work until it's entirely cranked up, this can become worse. This is when you'll need to figure out which of your apps is acting strangely and put a stop to it.