The shortest explanation: a detached elite discourse about magic and its causes, combined with the theological upheaval of the 15th and 16th centuries, created an environment in which peasant accusations of witchcraft were understood in terms of diabolism by civil authorities. Don't worry, I'm going to explain myself.
Let me try to give the general narrative. Kieckhefer gives a good description of thought on magic during the Middle Ages. The official disposition of the Church towards magic followed Augustine's renunciation of magic as demon-powered trickery, and altogether unacceptable. Still, acts we would consider "magic" today abounded on all levels of society: medicine, for instance, almost always involved sympathetic magic, in which some herb or animal parts were used for healing due to perceived connections between the afflicted organs and the medicine. Types of magic, like this, which interacted with objects in nature to access secret (occult) powers, was called "natural magic" by its adherents, and was practiced relatively widely.
This changed in the eleventh and twelfth centuries, when Greek and Arabic texts began to appear. These described forms of magic previously unpracticed in the Christian West: astrology and alchemy, most notably, and also the Neo-Platonic/Hermetic corpus. This created a surge of interest in the learned classes about magic, and many wealthy men began studying magic as an art form; by the time the Renaissance took off in the fourteenth and fifteenth centuries, the phenomenon of the "Renaissance magus" was established.
This began a conflict about the nature of magic that grew quite intense: the Church, mostly, took Augustine's position and denounced the new magic as dealing with demons. When the Reformation began, Martin Luther and John Calvin both aggressively attacked magic and magical ideas. The disposition of all three major Christian sects (Lutheranism, Reformed/Calvinism, and Catholicism) towards magic was therefore negative, and they all effectively agreed that all magic required working with demons. In an era where everyone was concerned with heresies within Christianity, the use of magic became a form of heresy in which Christianity was denounced by its practitioner in exchange for unnatural powers (or at least illusory powers). Natural philosophers, who might still practice alchemy or astrology, began to focus more on empirical experimentation than with explicit magic.
This discourse about magic, however, was restricted almost entirely to the literate elite. Peasants continued practicing "natural magic", typically performed in villages by widows and spinsters as a source of income, often supplementing begging. When everything went well in the village, they went unmolested. However, when misfortune befell the village, peasants might accuse this widow of using "black" magic to harm them in some way. From the peasants' perspective, at least at first, there was nothing demonic or Satanic about the black magic; instead, they saw a crime akin to theft, murder, etc., performed by magical means.
However, when certain magistrates heard these accusations, their own training about magic caused them to see demons at work. The accused were imprisoned and questioned with torture: as Levack argues, leading questions by torturers about dealings with demons "invented" devil worship among these witches. Invariably, the accused would confess to whatever they thought the torturer wanted, and essentially created ideas of selling their souls to the devil or demons, having sex with Satan, etc.
Once these confessions were extracted, the only judicial solution was execution, typically by burning (as was traditional for heretics). The sensation of the execution, and the lurid details of the confessions, caused a spreading panic about the presence and existence of such demon-worship. Accused witches would often state that others worshiped Satan at so-called "sabbaths" to try to gain leniency, creating cascading networks of accusations and trials that led to large numbers of executions regionally—indeed, the witch trials themselves were carried out almost exclusively by local authorities. Some accused witches confessed before torture, perhaps believing that their death was inevitable anyway; others came forward and confessed without being accused, perhaps truly believing that their traditional magic was demonic and that they had sold their souls. By the end of the peak, witches' sabbaths grew in the collective imagination of witch hunters to include thousands of (mostly) women, who Satan himself flew in to attend the gathering. The terror was palpable—the best modern analogy is, perhaps, the American experience of McCarthyism. No one was safe, and the basic fabric of society seemed ready to be broken.
Much like McCarthyism, however, the panic reached a tipping point where even many credulous people rejected the claims of these sabbath and even the existence of diabolism. Where witch hunting persisted, increasingly centralized judicial systems began to constrain the ability of regional authorities to prosecute the witch trials. The period of religious peace following the Peace of Westphalia in 1648, combined with growing elite skepticism about all magical claims, calmed the fears that drove the witch hunts. By the eighteenth century, Enlightenment thinkers were already lambasting the witch hunts as a sign of the backwardness of the preceding period.
EDIT: I just want to say that there's much more that I didn't get into, here—there's also a strong gendered component to the witch-hunts, firstly, and also connections to be drawn with ritual murder trials. This is only the broadest narrative.
Sources:
Kieckhefer, Richard. Magic in the Middle Ages.
Levack, Brian P. The Witch-Hunt in Early Modern Europe.