Code doesn’t necessarily have to be confidential. “Secret recipe” algorithms, maybe.
It’s about trade-offs. If you must have “trade secrets” amongst your code, perhaps you can keep that code available only to whom you trust will follow your wishes with it, and have separate repos to share wherein you do not care as much about collaborators “stealing” the code.
As soon as you let someone into your codebase, almost anything can happen, right?
There are cases where it would make sense to sacrifice risks related to code-copying in order to have faster/better development.
Also, what’s stopping anyone working at ANY company from taking the company code and doing whatever they want?