Intel is best thought of as two businesses, where their historical dominance in one (actually fabricating semiconductors) protected their dominance in another (designing logic chips), despite not actually being the best at that.
Intel's fabs represented the cutting edge in semiconductor manufacturing, and their superiority in that business almost killed AMD, who just couldn't keep up. Eventually, AMD decided they wouldn't try to keep up with cutting edge semiconductor manufacturing, and spun off their fabs as an independent company called Global Foundries in 2009.
But Intel hit a wall in progressing in semiconductor manufacturing, and made very slow progress with a new type of transistor known as a finFET, with lots of roadblocks and challenges. The biggest delays came around Intel's 10nm process, where they never got yields quite to where they should have been, while other foundries like Samsung and TSMC passed them up. And so their actual CPU business suffered because AMD, now a fabless chip designer, could go all in on TSMC's more advanced processes. Plus because they were fabless, they pioneered advanced packaging for "chiplet" designs where different pieces of silicon could be connected in a way that they acted like a single chip, but where the different components could be small enough that imperfections wouldn't hurt yield as badly, and where they could mix and match the cheap processes and the expensive processes to the part of the "chip" that actually needed the performance and precision.
Meanwhile, Apple was competing with Qualcomm and Samsung in the mobile System on a Chip (SoC) systems for phones, and developed its own silicon expertise. Eventually, they were able to scale up performance (with TSMC's help) to make a competitive laptop chip based on the principles of their mobile chip design (and then eventually desktop chips). That allowed them to stop buying Intel chips, and switch to their own designs, manufactured by TSMC. Qualcomm is also attempting to get into the laptop/small PC market by scaling up their mobile chip designs, also manufactured by TSMC.
Intel can get things right if it catches up with or surpasses TSMC in the next paradigm of semiconductor manufacturing. The transistors are changing from finFET (where TSMC has utter dominance) to GAAFET (where Intel, TSMC, and Samsung are all jockeying for position), and are trying out backside power (where the transistor gates are powered from underneath rather than from the cluttered top side). Intel has basically gone all in on their 18A process, and in a sense it's a bit of a clean slate in their competition with TSMC (and to a lesser degree, Samsung, and a new company out of Japan named Rapidus), and possibly even with Chinese companies like SMIC.
But there are negative external signs. Intel acknowledged that they don't have a lot of outside customers signing up for foundry services, so they're not exactly poaching any clients from TSMC. And if that's happening while TSMC is making absurd profits, that must mean that those potential clients who have seen Intel's tech under NDA might see that Intel is falling further behind from TSMC. At that point, Intel will struggle to compete on logic chips (CPUs against AMD and Apple and maybe Qualcomm, discrete GPUs against AMD and NVIDIA), if they're all just paying TSMC to make the chips for them.
So I don't think all of their layoffs make a ton of sense, but understand that they're really trying to retake the lead on fabrication, with everything else a lesser priority.