Well, I know naval architecture, so I'll try to relate what I know to aeronautical engineering.
When designing a vessel, you look at forecast stress levels. We usually build ships to withstand a 25 year stress. A lot of factors go into the figure, which means the 25 year stress for the Queen Mary is different that that of a Bertram 54. Sure the bertram goes offshore, but it isn't a transoceanic design, and won't meet the same conditions or stresses as a ship. It's just a statistical concept for generalized areas of operation.
After you design a ship to withstand it's prerequisite stress levels, you can forecast a service life for that vessel. Depending on the margin by which it can withstand those stresses and other factors, you may give it a 30 year service life.
Let's say two nearly identical vessels suited for the same purposes are proposed for a 85' motor yacht. One company builds a handlaid fiberglass hull and superstructure and the other company builds an aluminum hull and structure and both have comparable value. The owners of these vessels decide they want to operate their boats on the gulf of mexico, instead of the atlantic. These boats were built to survive crashing through the cape, but now they are destined for more gentle seas...
thirty years later a marine appraiser inspects both vessels, and finds that while the fiberglass hull is in perfect condition, the aluminum hull has sustained severe metal fatigue with associated microscopic cracking. While neither hull ever met its 25 year stress, one is destined for the scrapyard, while the other was sold with considerable profit.
Why did one outlast the other? Because the 25 year stress played a major role in determining the life of the fiberglass hull, but was less important in determining the life of the aluminum hull; even though both had comparable lives. Just imagine that the fiberglass hull could not have survived it's 25 year stress twice, which the aluminum hull would have. The life of the metal hull was influenced more by its salt water environment than its ability to survive a rogue wave.
I think with a little imagination, you can understand my point: The service life of two different aircraft may depend on varying factors. Factors other than the statistical 25 year stress it was designed to withstand.
In addition, as Meyrowings said, advances in metallurgy and testing methods allow us to better estimate the remaining life an aircraft has. This may vary between aircraft of the same make and model. The maintenance department will use ultrasound, x-ray specs, UV dyes, and other methods to inspect each aircraft in the fleet to determine its condition. Given that info, management decides which aircraft are not worth retrofitting and updating; and retire those aircraft accordingly. I suppose it's just rather arbitrary.