Consider the argument for holding Bakhmut (suggest reading the whole thread):
To quote Star Trek..
"Destroying an empire to win a war is no victory. And ending a battle to save an empire is no defeat."
If Ukraine holds out in Bakhmut and gets decimated in the process, the victory will be hollow.
Better to fall back, regroup and press on elsewhere.