Tech companies generally get away with paying less than their fair share: https://fortune.com/2019/12/06/big-tech-taxes-google-faceboo...
Also consider that all the workers are also tax payers and they want the company to continue existing, their taxes would also go towards protecting the bay. Their tax dollars wouldn't exist in California if those tech companies weren't there.
In fact, it's from places all over the world, significantly poorer places, where the money would stretch even further.
You're making it sound even worse.
Edit: The main point is that nobody can say that San Francisco has less money with those tech companies operating there than they would if those tech companies left. They are among the richest places on earth and should easily be afford any measures that can be afforded anywhere.