They often work with commercial vendors who collect salary data and sell that information to the employer. See, for example, American Electronics Association Salary Surveys or Radford Associates. For the jobseeker the most useful salary information comes from trade and professional associations that survey their members on a regular basis. If you're lucky there will be a geographic breakdown that highlights your area or a company breakdown that distinguishes between larger and smaller companies. When you combine their feedback with the salary information you already have, you'll have a better idea of how you want to approach the salary offer.
Companies establish a salary schedule and everyone knows what everyone else makes.
Government agencies and nonprofits are often up front about who makes what. You can go into the personnel office or take a peek at the budget and find out what others make. It's to their advantage to sign you in at the low end, saving money and giving you an incentive to work your way up. See the resources in Salary Negotiation Strategies to learn how to position yourself successfully. If you've been asked for a Salary History early in the application process, you have some decisions to make.