How do you ensure job security in a hard economic situation like this?
Regardless of the percentage of workers a company wants to layoff, no company wants to do away with staffs that are strong asset to them. Normally, when laying off workers, it's usually the ones that are easily replaceable that are layed off while the well experienced one are always allowed to stay and even if for some reasons well experienced workers are to be played off, it's not always deficult to get another job as long as you're highly skilled at what you do. There's not a thing as 100% job security in any industry except you own the business. the only way to ensure that the likelihood of being part of those that would be layed off is reduced is to increase your value and upgrade your portfolio constantly while still working under the company.
The effect of the bad economy the world is facing is affecting companies in different forms and alot of them are looking out for means to cut down cost. Setting out a plan B wouldn't be a bad idea because in this competitive tech industry, if you're an average skilled person, your job security is never guaranteed.
Does knowing about layoffs make you want to avoid corporate work?
Avoiding corporate works is only a thing when you have options of getting another job so easily. We are living in times when most workers don't have much choice with the decision of doing iether corporate job or private jobs. If what you can lay hold of is any of the two, you just have to work with them with the reality that you're definitely not working for that firm forever.