Great question — answering as the UphillTech team:
You are right, it should be a contractual obligation over who owns the source code. Many vendors will sell the finished product to the client but keep the source code, others will give the whole thing away (which is S.O.P. with our company) I imagine it gets done, just not sure as far as the scope or depth of the copying. I can't think of any well-known examples (primarily because business between two companies isn't often publicized), but a personal example is when we developed a much more flexible time-tracking system in one of our client applications and it turned out so well that we implemented it into our own personal time-tracking system (which wasn't that great out the gate).
Full answer by TheTXI: https://stackoverflow.stackexchange.com/a/760200 (CC BY-SA 4.0).
Need it done for your business? UphillTech.