That's a bit broader than I was thinking... thanks for clarifying! I'll mull it over a bit and see if something coherent comes out of my brain.
There is some academic literature on the subject you might find interesting. Back in undergrad when I realized that this was all a thing, I spent some time at the university library getting an understanding of the anthropological perspective on magic. Early on in anthropological research, there was a desire to put a wedge between magic and religion, largely due to ethnocentric biases, and that trend has reduced over time as researchers have learned to be more impartial and objective in studying different cultures. A central theme I got out of looking at many of these works, though, is the tremendous difficulty in defining what magic is. The take O'Keefe had in "Stolen Lightning: A Social Theory of Magic" was one of the more fascinating ones, but like many anthropological studies, it doesn't take into account the modern occult revival or the prevalence of magic in the New Age and Neopagan communities. For that, Susan Greenwood's works (i.e., "Magic, Witchcraft, & the Otherworld", "The Nature of Magic", and "Anthropology of Magic") are excellent to take a gander at and I'd highly recommend them. There are doubtless dozens of works on this that I haven't read or even heard of. Sometimes one must get creative with search terms, as things we might regard as "magic" won't be described as such by academics.