There's way too many factors to be able to say what the common reason is (if there is any).
You've worked for 'various startups', so obviously you're good enough to be hired by someone. You just need to find the right job.
I'd wager that more than 50% of candidates that get rejected have it happen for reasons completely unrelated to them. Last minute hiring plan changes, an interviewer having a bad day, disorganization, and arbitrary HR hoops can all be valid reasons. Also don't forget that hiring processes vary greatly company to company, and it was way more informal/disorganized than you are imagining in your head.
It's not very clear from your post, but are you making it to on-site interviews? If you are passing phone screens and getting the take-home, but not getting invited to on-sites, you could be punching above your weight a little bit. Try applying for more junior positions and see if you are seeing the same results. If you are making it to on-site interviews but not getting offers, it is either your in-person technical interviewing skills, or more likely, your personal skills.
Practicing technical interviewing skills is easy. Being 'likeable'/passing the 'culture fit' is much harder to nail down and really depends on the company / interviewer.
Four rejections is really not that many in the grand scheme of things. Keep applying, keep interviewing. Ask a friend or find someone online and practice interview them. Try to see things from the other perspective, and pretend that you really are going to give someone an offer. Hiring someone isn't as easy as 'we need someone, and this person can code'.
Also, consider expanding your search outside the bay area. I don't live or work there, but it seems like everything tech is exaggerated there. You are competing at the highest level there, so getting an offer will be harder than other cities.