The same can be said of attacking the Rodney when it clearly was not the Bismark. How experienced were the air crews, what orders did they have, was there any communications present, were they aware of the warship? All these things and a 1000 other items play into the incident. The fact the attacker was USAF should give you a clue as to how well trained he was in identifying ships. I would not be surprised to find that the pilot was never cross-trained to ID shipping - unlike his USN counterparts who do see ships often.
In the heat of combat - shoot first is a formula for personal survival. We have suffered a number of friendly fire incidents in recent years but once again - the total number of such incidents have declined dramatically since the introduction of better communications and training. The days of Vietnam had loads of variables that do not apply today.
It is easy enough for us sitting here to judge those who did the shooting. One has to place yourself in the shoes (or boots) of the shooter. Would you open fire if you were not sure - absolutely sure? War is never a 100% sure business. No one wants to kill friendlies and everyone wants to finish the job quickly. The balance between training, experience and aggression is a fine line.