You are misunderstanding the matter of patents. Modern patents exist precisely because of the inevitability of industrial espionage, which is largely practiced by all developed countries. The goal is that, even after a trade secret is stolen, it will be made useless because nobody can use that information. So the goal is not to "share knowledge", but to avoid the practical use of knowledge that was shared by any means.
Also, you are mistaken in thinking that, by publishing a patent, the company is sharing knowledge. Quite the contrary, the contents of a patent gives only the minimum necessary to protect a crucial aspect of a business secret. Most patents are opaque and don't give any concrete business information that be used to successfully replicate what it is trying to conceal.