Whether you buy it, borrow it or build it; you’re locked in to the chosen solution.
Homegrown solutions are often harder to escape from than commercial or FOSS solutions.
It’s sometimes easier to escape from one commercial solution to another as companies will provide migration tools and docs as part of their competitive strategy.
You can mitigate solution lock-in through good architecture, but you can never eliminate the cost of change.
For commercial software (or FOSS-as-appliance) then you're stuck going along wherever your vendor wants to take you.
Example - I was working with jira server for several years at pretty small company. As business grew, there were better and worse moments and sometimes there were more important costs, than another yearly support fee.
Atlassian decided to drop this model and tries to force everyone to the cloud. They say that migration will take 9+ months.
That means if they ever do such change again it will take full annual cost of the license to get rid of them, with no option to avoid it.
That's huge risk, liability and often productivity gains are greatly overstated.