In order to understand how witches could fly on broomsticks, or at least believe they were flying, we need to consider the plant that Ron Weasley is holding in this still from a Harry Potter movie. The plant is commonly called mandrake (genus: Mandragora; there are four known species) and belong to the same family (Solanaceae) as the more famous deadly nightshade plant. The plants typically exhibit a bifurcated root that sometimes makes them resemble human figures. Their odd shape and the presence of psychoactive alkaloids have combined to give the plant some notorious religious associations, at least four references by Shakespeare and some beautifully haunting songs and poems. All of these can be explained by the actions of just a few chemicals found in the plant that have a single, very specific effect in our brain.
The plant contains scopolamine and atropine; these two chemicals can produce a floating feeling of euphoria at low doses and true visual and auditory hallucinations at higher doses. Both drugs have the same mechanism of action within the human brain; they block the action of the neurotransmitter acetylcholine. Within the human brain are numerous acetylcholine pathways that influence the function of the cortex, hippocampus, and many other regions. Within these various regions, the actions of acetylcholine allow you to learn and remember, to interpret the meaning of sights and sounds, to regulate your attention and mood, and to control how well you can move. Thus, anything that affects the function of acetylcholine neurons has the potential to affect all of these brain functions.
The original witches flying ointment, so called because of its reputed use by medieval witches, was probably an herbal recipe that contained extracts from the Mandragora plant, as well as poplar leaves and fireplace soot, all of which were held together with animal fat or clove oil. In a ritual performed in the nude, the witches would rub the ointment on their foreheads, wrists, hands, or feet. According to Abramelin the Mage (1362--1460), a Jew from Wurzburg, Germany, who wrote a series of books on magic and the occult, the women would also "anoint a staff and ride on it...or anoint themselves under the arms and in other hairy places."
It is now believed that their experiences may underlie the origination of stories about witches flying on broomsticks. By anointing "a staff" with the ointment and then riding on it naked, they would inevitably rub the ointment into the mucous membrane of their labia, which would ensure a speedy absorption of the lipid-soluble active ingredients of the plants in the ointment. According to more modern accounts, the sensation produced by extracts from this plant include both visual hallucinations and a floating, light-headed feeling; it's not hard to appreciate why these women from the 14th and 15th centuries might have reported an experience similar to flying through the sky while straddling their broomsticks.
In addition, it's also not hard to imagine having a conversation with your favorite black cat while under the influence of this plant. Honestly, I think that I would give the mandrake extract a try if I thought that I could use the opportunity to convince my cat to stop digging in the plants.