Layoffs in particular are like this because they're planned very quickly by very small groups of people. Rumors of impending layoffs obliterate morale, so the people in charge do everything they can to maintain secrecy and minimize the time between people hearing about layoffs and the layoffs taking effect. This basically always translates to random-seeming decisions - priority 1 is to cut costs by X amount, choosing the right people to cut is secondary. This means that, for example, engineers that have received performance-based raises are punished since, on paper, they do the same job as lower-performing but lower-paid engineers.
Not defending the process(the right way to break this equilibrium is statutory requirements for layoffs a la the WARN act) but that's why you see the outcomes you do.