...Heck, they apparently survived the scuttling of the ship over Genesis, since they're still there in the NCC-1701-A!
The identity of the ship might well be independent of any of her physical structures. Indeed, this might be the very reason for the refit.
Presumably the Feds and the Klingons had been escalating for a war prior to "Errand of Mercy", possibly ever since Burnham's War a decade prior. After that adventure, though, we get this something they call the Organian Peace Treaty. Yet Klingons don't seem to believe in peace much, treaty or no treaty. The actual content of that treaty thus could be an arms race limitation deal wherein the two sides agree on quotas of shipbuilding, perhaps type by type - much like nations between the World Wars here agreed on such, in the hopes of gaining the upper hand on their competitors, or maintaining it, or at least not losing too much of it, all without bankrupting their own economy.
So Starfleet would be motivated to "refit" an old ship when the treaty tells them not to build a new one - even if the old ship simply ceases to be and a new one emerges in her place... Quite a bit of that happened between the World Wars, too.
We don't know if starships have keels or skeletons on which the rest of the parts hang. If so, NCC-1701 might still retain her interior framework, even though the exterior is of wholly new shapes and dimensions. This assuming that there's some point in retaining the framework, rather than dumping it along with the old powerplant, the old engines, the old weapons, the old computers, the old chairs...
If starships are more like cars, though, and the outer hull itself is the load-bearing structure, then it's a massive undertaking to alter the curvature of the secondary hull by two feet, compared to swapping a panel welded to a girder. Essentially, the dockyards would have to melt the old ship for raw materials and mold a new one out of those.
Timo Saloniemi