They weren't firing indiscriminately, they were firing at the army of cops running at them with guns drawn. That's why this could have been avoided. Pick a better spot for your next ambush...
It's still not known who fired first, the cops or the robbers....