Companies are in business to make money, not to provide jobs.
The sooner you realize that companies will let you go at any time, no reason legally required since it is an “at will” employment relationship, the better off you will be.
Always be prepared on where you will go if laid off. Always keep an emergency fund covering 6 months expenses so getting laid off doesn’t ruin yours and your family’s life.
An old book from the 1990’s pointed out that successful people accept the fact that for things you have no control over, don’t worry about / try to change them, just realize how they are.
As a regular high tech worker, you are not in control. Realize this and prepare for the worse.
A sound advice by @6frn+18yqs766 .