Excellent insight. And agree to your theoretical conclusion to some extent.
To share contractor perspective: a problem I've identified is ambiguous overlap of ownership/maintainer role of project code between contractor and contractee staff (or lack thereof). So a slightly alternate conclusion is that it's up to the contractor to exert authority over the code they provide to the contractee even if that means charging more to ensure said code shall be maintained well into beyond original production date; or doing the hard but necessary things like engaging directly with contractee and its staff at ground-zero and not-to-mention the customers said project serves so as to stay dialed into the picture for as long or as intimately as necessary to ensure optimal results.
It is not always a rewarding experience, and can be demoralizing at times because internal staff can often view contractors as outside threats to their own jobs (which is understandable; but actually is part of the value in hiring outside contractors from time to time as it keeps staff on their toes) and so you may often be feeling like you are on the outside knocking on the window just to get basic access to assets, servers, or people/gatekeepers responsible for granting you what you need to get said work done, yet...
if contractor doesn't exert this extent of dilligence, or lazily assumes the company will maintain said code by means of its own devices - it will become lose lose for both sides as the contractor will be blamed when things start to break or when internal staff eventually & inevitably are requested to introduce new features on top of the now outdated 'foreign codebase' they begrudgingly must now maintain - which can conversely result in long drawn-out 'new platform' projects that set back said company by months or a year or more resulting in yet more need for contractors to fill in gaps again and as such this never-ending cycle continues.
At the end of the day if you are contractor you are indeed expendable & temporary and so its best not to get emotionally invested; be results focused & get paid for your time, do your best and at the end of the day that is all you and your client need - at least until the next cycle begins.