I was laid off once. The reason on paper was budgetary, times are tough, etc. But the real reason was that I was a bad fit for the role - for a variety of reasons.
I got pipped, and foolish me tried hard to work on the items in the pip (to no effect). The layoff came right on schedule.
A few years later, I was chatting with an old coworker and I came to find out that the director of engineering had demanded it. It was in direct response to me refusing to participate in building a knowingly DMCA-violating product.
The pip was theater. The "times are tough" bit was theater. The reality is that the director wanted me gone, and that is how they did it for legal coverage reasons.
I don't really blame the company - I was a bad fit, and I can see that clearly in hindsight. But it did teach me never to accept budgetary layoffs at face value.