First of all, employers are trying to make it look like it's a substantive ethical rule not to disclose your salary. But that's instrumental. It serves their interest, not yours, and the interest is to be able to pay less to other people.
Pulling the trick off and paying more to the people who are more likely to fuss or who have a better perception of how much they should be making, is downright offputting and, in my view, immoral. Freedom of contract, that is the fact the employee agrees without coercion to such proposed terms (but while being engineered into thinking that he's getting a good offer, while everyone at the company is commanded to shut up about his earnings), does not in my opinion deal away with this problem and make such actions fair. There is a reason why some companies use tariffs.
If you have something like, "employee will keep confidential all information pertaining to the terms and conditions of his employment," in your contract, then it may be construed to bind you to silence about your salary even among your coworkers (although the first object of that kind of a clause is the business competition of the employer's).
This said, some people get paid really according to their talents and/or how much money they bring into the company's coffers, which may be more than the other employees at the same tier do. Thus justifiably will that person earn more. The person will possibly be on a faster track for promotion too, but not necessarily so, because, for example, a superb salesman can earn more sales than his own manager in direct action but be unable to manage a team (e.g. great skills, poor leadership) and there might be some person who has poor substantive skills, but great leadership and administrative skills, not necessarily making him a bad material for a boss. So sometimes those "unequal" salary/promotion decisions are actually reasonable, even positively wise.
What's more, we generally have little reason to complain, if we're getting treated fairly, just because someone is treated better who doesn't seem to be deserving. First, *our *treatment is fair. Second, the boss has more info, he's the one responsible or possibly the owner (or appointed by the owner), it's his good or bad decisions that he needs to make, it's his problem, not ours (we have no claim on the position or salary, let alone the company itself).
In your case, I believe you should tell them you didn't know they would find it disagreeable, you won't do it again if they tell you not to. I'm not sure about apologising.
If anyone starts insulting you or shouting, tell them to stop. If they tell you committed a major ethics violation, it's up to you what you do at that point, although I would debate the ethical nature of the rule (and I would get fired). You could probably tell them no one told you about it or showed you any written policy, so you didn't know and it's not something that a newbie will know instinctly.
No matter what they try to tell you, shutting up about your salary is not some fundamental constitutional and natural obligation that every human should be aware of from birth.
Just my thoughts on the matter. It's probably worth noting that employers deserve respect (and obedience--within the contract) pretty much the same way parents or legitimate authorities do (although not to the same extent maybe). Even if they are wrong or acting immorally, the matter must be handled with respect (which doesn't mean objections can't be raised).