Assuming a company is paying well or above average for the market, I'd expect that they'd want to capitalize on that when hiring. People are more likely to apply and it's free PR. Yet I've never heard of a company that encourages employees to post their salary to Glassdoor or similar websites - in fact, it's almost always forbidden. Why is that? One thing which comes to mind is that the company doesn't want employees to know how much others are making, but that seems less of an issue since salaries are posted anonymously.
For example say you are on 20,000 a year. You look on glassdoor and it shows that your company pays 30,000 a year. So you now know that one of your colleagues is on 10k more than you, who does the same or a similar job. It can cause frictions in the workplace.
Companies sometimes underpay staff because they can (like if they are promoted through the ranks, they may not know how much they are worth). If people know what others at the company are paid, then the lower paid members will ask for more money.
Whether this is fair is a completely different question, but that's why it happens anyway.
You can consider salary is part of financial data a company is not willing to be known by competitors or clients. Would a company encourage its employees to publish on a public website the fresh new business plan, or the BtoB prices grid? This doesn't make any sense.
If you work in a field where competition is rude between companies, any information letting competitors steal your employees for a 10% salary upgrade can be seen as critical data.