We have to consider whether medical ethics extend to a medical practitioner's entire life, or just his or her practicing of medicine.
Bashir readily kills people when acting in his role as a Starfleet officer, general swashbuckler or private citizen. He's not a doctor all the time, nor does he pretend to be one: there is no equivalent of the Red Cross sign to make Star Trek medics non-targets in warfare, and no practical indication that medics wouldn't be well-armed combatants, either.
Crusher could be a tender and caring doctor most of the time - but when called to erase a memory as part of her general duty to protect the Federation, she can and will drop her medical persona, take up arms and inflict damage on the enemies of the Federation. (And then return to her medical duties as if nothing had happened.)