In 1988, the USS Vincennes shot down an Iranian airliner, mistaking believing it was a F-4 fighter jet on an attack course. I’ve never read a convincing description of how that happened, but at least one other nearby ship, the USS Sides, identified it as a civilian plane
Here is what happened (The VINCENNES shoot down was naturally a big topic when I went through AEGIS console operator training as a young Ensign).
We were involved in hostilities with Iran at the time. USS VINCENNES was at that time engaged in running gun battle with Iranian patrol boats and naturally expecting further action (the Iranians had fired at a US helo in the Strait of Hormuz and VINCENNES was returning the favor).
That was what was going on at the time the Airbus departed from Bandar Abbas. The Bus was flying a normal airline flight profile squawking the appropriate ATC code. VINCENNES was tracking the Airbus along with everything else in the air.
What happened from there could be described as confirmation bias facilitated by lax operating procedures.
CO of VINCENNES likely expected further escalation. An aircraft had departed Bandar Abbas (a joint civil/mil airfield where Iranian fighters were based) heading towards them. While they were tracking the contact under heightened tensions, someone (without identifying what watch station they were standing) blurted out over the intercom the statement that 'he's descending' at which point the CO assumed they meant the contact heading towards them was descending and he gave the kill order.
It is believed that what happened is that at one of the air defense consoles the track data being displayed had swapped from the Airbus to a nearby F-14 descending to land on the carrier and whoever made the statement was watching the radar picture of flight heading toward them while looking at the altitude display data for the wrong track.
So, in essence lax procedures combined with heightened tensions and a ship leaning a little too far forward in the saddle (after STARK, no CO wanted to be the first to take a hit before firing back) led the CO to believe he was being attacked and he responded accordingly.
A tragic accident without malicious intent. I suspect that something similar happened with the Ukranian 737.
Hope that helps explain it.