I've been laid off a few times in my 35-year career. Being laid off felt like a betrayal to me for a long time. But I was operating under a false model: that because I worked hard and did good work, that the company would value me and take care of me.
I also used to shake my fist at the bad outcomes of stupid decisions made by people above me.
It took me this long to realize that this is all a game of chance. Me choosing a company to work for is me playing the odds. The decisions my superiors make are bets, too. And sometimes, even good bets don't work out.
It's still worth it to work hard and deliver what your management wants in spades. I've been brought along to any number of new employment opportunities because I'm remembered well for being a person who did those things.
I've come to see my career as a series of stops, and my current stop is just what I'm doing right now.