When juries deliberate, they discuss their reasons for thinking this or that. Basically, by telling the jury to disregard something, the judge is saying that this shouldn't be included in the decision-making process.
Of course people can't just take things out of their heads, and of course the legal representatives take advantage of that fact.
At our GP surgery, there are a couple of doctors who won't consult on birth control matters for religious reasons.
There's just a sign at the reception saying that if you need to discuss birth control, please let the receptionist know and they'll be sure to assign a different doctor.