If a physician is described as a quack, he is to be avoided, but how did the term come about?

The word has nothing to do with ducks, but comes from the Dutch quacksalver, from quacken meaning prattle and salf meaning a healing ointment. 

A quacksalver then was someone who prattled on about the efficacy of his remedies.

Quack came to describe someone who purported to be a doctor but was really just all talk. Such a doctor practised quackery.