We've got a few more modern examples, Huascar is a neat old ironclad we Dutch have two Ram turret ships from the 1860's, HrMS Schorpioen and HrMS Buffel which are in pretty good condition, HMS Warrior is in good shape too and of course there was SMS Goeben/ Yavuz Sultan Selim which was a battlecruiser build in 1911 and scrapped in 1973, she was in continues service for about 50 years without really big refits whatsoever.
As for Trek ships, it would be totally redicilous to assume that those would have the same limited lifespans as current naval vessels, the materials are a thousand fold better then we can even dream off nowadays, they don't corrode, they don't develop metal fatigue and they will be manufactured to incredible standards.
I don't think its all that surprising to see Mirandas flying around or Constitution refits or whatever, I even wouldn't be surprised that Oberth class vessels started out as fleet scouts and later on were delegated to science work after a century or so, scoop the weapons out and throw some sensor packs in tadaa, there you go.