Many attacks on police are a form of ambush, a proven effective deadly military tactic. The military trains extensively in ambush/counter-ambush tactics. Yet, despite having the best training, equipment, and tactics, our troops continue to suffer ambush casualties in Iraq and Afghanistan. That's how effective this tactic can be.
Police are also engaged in a war, albeit one that's far less intense, against bad guys who employ very similar tactics as those used by guerillas and insurgents. Hardcore bad guys have survival mindsets. They understand fight/flight, and they train to defeat police tactics. Consequently, we must always have strong officer survival attitudes, train realistically, constantly hone skills, and never let our guard down.
Although the above incidents did not involve SWAT, they had clear potential for turning into SWAT situations. SWAT has the advantage of enhanced training, tactics, teamwork, equipment, and weaponry. SWAT missions usually involve "known" danger, deploying multiple officers, with weapons at the ready.
In contrast, first responders usually deal with "unknown" danger, and cannot draw their weapons until/unless a threat manifests. All law enforcement agencies have strict rules governing drawing, displaying, pointing weapons. With the constant threats of civil, criminal, departmental action, the hope is that no officers will hesitate to defend themselves when they need to. This was not the case with the above two officers who never had a chance to defend themselves.
Surprise, shock, and speed are proven effective tactical principles. SWAT teams take advantage of action/reaction, buying precious time by first surprising then shocking their adversaries into a temporary inability to react and then overwhelming them with speed before they have time to recover. Many suspects also use these same principles against police.