Personal anecdote. A company I worked for fired the more costly tech support staff right before an important partner product launch which left a bunch of undertrained customer service reps supporting the new product which gave a bad experience to customers. It also irritated the partner because the training the reps received essentially told them that almost any problem needed to be referred to the partner, swamping them with customers wanting them to fix a problem that wasn't theirs. They then had to scramble & rehire a tech support staff.
Take Intel's Itanium project which has struggled on for 16 years, yet Intel still has resources devoted to it. Sometimes you cannot just kill a very unsuccessful project & it can take many many years to wind it down.
You could also look at any need for layoffs as being a miscalculation by the company. When Yahoo announces 2000 layoffs, does that mean they're being efficient by cutting staff or does it mean that they've had 2000 employees on staff that shouldn't have been there in the first place & for how long? Why didn't the indexes and metrics in place tell them to not hire these people?
Also the government is not immune to layoffs. They have actually been one of the top organizations laying people off over the last few years.
I do not know if you are familiar with how big companies work, but usually when you reach a large enough size, such companies start to track "productivity indexes" between their departments and against competition, when comparison is available. SUch an index would look like = sales of the department / headcount of that department, which basically gives you an "average value" of an employee in that department. Then in order to prove that you need additional headcounts, you need to have a high productivity index in the first place to justify it. So that's why big companies don't just keep growing forever: they start to become more efficiency-sensitive, and consider carefully the cost of an employee versus the actual benefit to have more.