Errr,it's completely and totally unrelated to that.
It's because we have tons of temps, vendors, and contractors, and don't want to have to owe them source code to internal systems.
The other alternative (remember that google is a monorepo) would be to somehow police them differently.
That is literally not worth the cost.
I don't see how having "some proprietary code that they would like to keep proprietary" is "completely and totally unrelated to" "not want[ing] to have to owe [someone/anyone] source code to internal systems"?
The implication of the above comment is explicitly that it's because of stuff we make available in public (IE google docs), and we actually literally do not care about that at all.