I've spent quite a bit of time thinking about this as I'm a former service member who is generally kind of paranoid of people breaking into my safe spaces. In the Marine Corps, there's pretty much two tactical options we are trained to choose from when taking fire: either immediately assault the enemy with fire and maneuver, or break contact and find cover.
An immediate assault should only be used if you know the relative size of the enemy, you're rules of engagement support an assault, and there's no hard cover available. Immediately returning fire increases the likelihood of getting your people killed, but retains the initiative, which is great if the enemy force is likely to advance on your position. There is no benefit of doing this if the enemy is just going to sit behind cover taking pot shots; better to draw them out and gain the cover advantage.
All of that is to say that the police had NONE of those qualifications. There is literally no reason not to pull back. By returning fire, they put themselves in MORE danger, and for no reason. That is the reaction that untrained animals take, not a disciplined unit.