Common Sense:
If you are a police officer, and apprehending a suspect.
Who is resisting arrest, refusing to comply with instructions and found to be armed with a gun.
Things are hotting up.
Once the officer(s) have decided to draw their weapons.
You can't stand around and spend 5 minutes, carefully weighing up the situation and asking BOTH the suspect and fellow police officer what is going on, who shot who, is he still armed, etc etc.
So once shots have been fired the police officers have to use the immediate decisions that their brains make for them.
You have to react VERY quickly, otherwise suspects can and will (in some cases) shoot the police officers DEAD (or injured).
So if either or both officers can reasonably make a super quick decision that it has become VERY dangerous and apparently the suspect is shooting at the officers.
They can/will and should immediately fire back.
There just isn't TIME to wait 10 seconds or 20 seconds or 5 minutes, because it will only take a bad criminal, 1 second (VERY approximately), to potentially shoot the police officers DEAD.
He was resisting arrest, and refusing to comply with the police officers requests. He was armed with a gun, and seemed to have it in his hand (if I understand the video correctly), while acting rather in an apparently uncooperative/dangerous way.
tl;dr
If you DON'T want to get shot by police, don't resist arrest, while having a gun near or even in your hand. It is extremely dangerous to do so.
It is VERY easy to quietly watch the video at home, while relaxed and with plenty of time and hindsight, and say "He shouldn't have done that". But you have to be realistic about what was occurring at that time.
The video is NOT 100% clear, and I don't fully know what the police officers were thinking at the time etc. But my quick and ready opinion, is that it was the suspects fault. The police were just acting how they (I would imagine) have been trained to respond, to (at least somewhat) violently armed and dangerous criminals.