Different people have different preferences, and some managers probably have mistaken beliefs about what is good for them and their employees.
From a negotiation standpoint, the employer (generally) wants to hire, or give raises to, the employee at the lowest possible total cost. Whereas the employee (generally) want to be hired, or get a raise, at the highest possible total cost. Where the cost analysis may not be the same for each side.
Now assume that that all other things being equal, and no information about salary rates are known, the employer's range for salary is $80-$100k, and the employee's range for salary is $70k-$90k. In this situation, the employer would love to hire at $70k, which they may be able to do if the employee doesn't know any better. Now, imagine that the employee had information about the employer's salary range, then the employee would smartly shift their salary range knowing that the employee was 'low'.
The same applies to raises. If an employee has no information about other coworker's salaries, then the 'standard' raise of 3-4% might be acceptable. However, if another coworker has a significantly higher salary, with similar responsibilities, then the employee may ask for a higher raise. They may or may not get that raise, but it's at least a possibility. One which the employer is likely to not want to have the employee know about.
The worst case scenario for the employee is to find out they are making significantly more money than their coworkers, in which case they have no further bargaining power.
So really, the question of whether or not it's a good idea to share salary information to other current or future coworkers comes down to whether or not you're on the 'employer' side (where additional salary information can only move your costs upwards), or on the 'employee' side where having no transparency about salary can prevent you from getting the best salary possible.
Since the difference between having salary transparency or not is so high, it behooves most employers to subtly discourage salary talks. So you end in a place where it is a possibly a violation of federal law (for the federal government), or possibly state law[0], to prevent people from talking about salaries, but at the same time people will almost always only post their salary information anonymously.
If all employees values transparency and fairness and would rather have a lower but more fair pay, them the transparency may work.
However, the employer typically derives more profit per unit of work if they employee makes less. Also, if you are a good negotiator or you are the type to always threaten to leave if not given more pay you benefit from the opaqueness. If the company has a lot of good negotiators it may make sense to be more transparent to keep the overall wages down since no one can exercise that benefit.
There are probably other factors such as supply and demand beyond individuals at specific points in time which need to be taken into account (surge pricing?) we need someone for this project now, so we will pay them a premium even if we would normally pay them the same as everyone else, even in consideration of long terms costs this may make sense.