Or, for another analogy: AI controlled units are like G2A missiles, while XCOM operatives are like multi-role fighter jets. The former missing or being destroyed is largely meaningless, as they're fundamentally expendable and typically used en masse. If the latter misses, it's a waste of time and effort; if it's destroyed, that's a large investment lost to a relatively meaningless attack.
After a mission, AI troops are essentially gone forever, regardless of whether they hurt anything or lived/died. After a mission, an XCOM operative that got hurt or killed is the loss of a meaningful asset. Thus, risking the former is trivial, but risking the latter is serious, especially if the risk includes a total failure state (missing and then getting shot) as opposed to a success in the immediate action followed by injury or death.
When you send a Ranger to melee something, you're already rolling the dice on whether they get hurt or killed. Adding in the possibility of them not even giving you anything in return for that risk is just insult piled atop injury.
Also it helps that in my game a fully-kitted Ranger still can't one-shot an Elite Lancer with melee unless they crit. Really helps slot the sword into the trash-cleaning/guaranteed finishing blow role.