The number one thing I've learned from being laid off was never to trust your employer. Trust people, if they've shown to be trustworthy, but never, ever trust a company. A company is not family, they're not your friend, and the perceived loyalty you think you've "earned" doesn't mean a thing if layoffs are coming. Treat your employment as a business arrangement. You get a paycheck in exchange for labor. Nothing less…
Humans are tribal by nature and companies are setup like a big tribe. We even call the guy (and it’s mostly a guy) at the top the chief! Feelings of “family” and “loyalty” are built into humans operating in tribes, and a real tribe looks out for its members.
So when the sudden wholesale internally orchestrated slaughter of a chunk of the tribe happens (metaphorically), it comes as quite a shock (the first time). Both for the people that go and the people that stay. The lesson is that a company is not a tribe.
That said, a company is also a collection of people and the relationships you develop as you work are just as meaningful as the ones you develop in other aspects of life. Loyalty to people is a perfectly good and reasonable thing.
So my take is, you should focus on fostering good relationships with your coworkers and hold loosely to the concept of the “company”. The company may screw you over, but good people will always try to do what is right.