Why is this a surprise? Tesla is a High Tech company.
After working in the High Tech world for most of my career, I've come to expect layoffs. Fully half of the companies I've worked for have laid me off, never for cause. I don't think I was ever singled out because of the expense of my salary. It was always because the company had made a business decision to downsize or close a business unit. Most of the individual leaders I worked for tried to hire me into the next place they landed, and were sometimes successful.
This business is speculative. Sometimes the money is there, sometimes not. Sometimes your product sells, sometimes it does not. Look at the statistics on the success of start-ups. Most of them fail. If you're working for one that fails, you get laid off. Other times the revenue is just not there to support a large business, so the owners decide to make it a smaller business, to fit the new revenue model. They don't owe you a living. This environment does not produce jobs for life.
The best thing to do is learn to read the warning signs, have an exit plan, and have some money set aside for when the time comes. Maintain your employ-ability by learning the latest marketable skills (on your own time if you have to). Be ready, be valuable, be well networked with your work community. This is how it is.