Police departments have fought legal battles specifically to avoid having any duty to protect civilians or to prevent a crime in progress if they so choose.[0] I do agree with you that they (not just in SF, but across America broadly) have in fact obviously failed on all levels, though.
[0]: https://www.findlaw.com/legalblogs/law-and-life/do-the-polic...