In the 1600's there were wide beliefs in magic. Many believed magic could be used to cure ailments and improve their lives. For those believers, it logically followed that the same magic could be used against their enemies. That became the basis for believing some had such special powers and were capable of making a "pact with the devil." Instead of dealing with their differences under the law or in some other civil way, many resorted to witchcraft.
Governments made witchcraft illegal and prosecuted it's practitioners. However the prosecutions were not based on evidence of something they did, rather it was based on suspicions of the people around them. Witch hunting rose to the level of a mania. Many people were tortured and for that reason, there were many false confessions and admissions to stop the torture. The easy way to get even with an enemy was to accuse them of witchcraft.
In the 1700's, more and more people became skeptical of magic and demanded a higher standard of evidence for conviction of the crime. Torture was removed as a tool of investigation. People were no longer prosecuted for the label used to describe them rather by the evidence of what they were accused of doing. It was the change in public attitudes about magic that put an end to it.