The 14 missiles weren't shot anywhere near Tehran & were surface to surface missiles that fly pretty low (so they can get passed the US Patriot anti-missile defense system). So the missiles that were headed to those Iraqi bases with US forces weren't the same as the one that struck the plane.
So yeah, the most likely answer is some inexperienced soldier panicked and fired a surface to air missile when he saw a plane fly overhead. It's possible there was something wrong with the plane's IFF (Identify Friend or Foe system) - the technology that exists so commercial airliners aren't mistaken for military aircraft and constantly shot down, according to some pilot on the news this morning.
In any case, it's an absolute tragedy - because these victims are the real victims of the recent escalation in tensions. A few families, parents & their kids, were dead in moments. A lot of the people were Iranian international students in Canada that had been visiting their families over their uni's winter break.
It's completely mental that Iran didn't put flight restrictions out the night they'd just responded to the tension by firing missiles at the US and they were obviously on high alert for any sort of military response from the US - delaying all departing flights out of Tehran for a few hours seems like it would have been completely reasonable to avoid the risk of innocent people dying. But instead they didn't and they took that risk... and a lot of innocent people died.
Tbh when I first saw the video of it on twitter - I thought it was a missile that struck the plane and not a technical error. Just because it was a plane going down in a ball of flames.