I have a rather odd headcanon for how magic works in Equestria. And since a few people (Actually, I can't specifically remember anyone asking about it except Eagle1Division
) have expressed some interest in it, I thought I'd try to give a detailed explanation as best as I can. I'm going to break this into a few parts for two reasons: one, I haven't fully formulated this theory and I can't really type it all at once, and two, because it's gonna get really philosophical and technical in the more specific bits, and I want to keep most of those separate if I can. Hopefully it's not too confusing! Enjoy!
The first thing to understand is what magic itself is
. I think of it as a special type of energy (actually, energy isn't the most accurate term, it's really more of a substance, if anything, but I'm going to stick with energy for ease of understanding), something that exists in weak concentrations pretty much everywhere. But it also exists in more focused concentrations in certain places. Especially living things capable of conscious thought.
In Doctor Whooves Adventures, a popular MLP/Doctor Who crossover audioseries, the Doctor can use his sonic screwdriver to communicate with inanimate objects due to the fact that, apparently, everything in Equestria is just a little bit alive, due to magic.
In other words, magic is life energy. Well, actually, a more accurate term would be consciousness
energy. It's the source of consciousness and "soul" for all living things, and even some NON-living things. Each said consciousness has its own magical "signature". I'm not sure exactly what it would be, maybe a combination of frequencies or something, but it's a unique quality of the magic that applies to the magical energy corresponding to a consciousness. The magical energy around everywhere else (let's call it "ambient magic") doesn't really have a signature, but the signature of any arbitrary quantity of magic can change.
When the Doctor is communicating with an inanimate object, it's not technically already conscious before he does. He's essentially using his sonic screwdriver to generate a new "signature" for the object's consciousness.
However, this could quickly dissipate once the Doctor is finished "talking" to it. Magic of the same signature has a weak sort of magnetic force towards itself, but if there's not enough of it, the signature will fade, and it dissipates.
Most normal conscious beings keep their magical energy because of a special, incredibly dense concentration of magic inside them, a sort of core. This core is much more self-gravitating and can thus keep a field of magic signature around it for an essentially indefinite period of time.
When the living thing this core is attached to (a pony, for example) dies, the core no longer has an anchor, and tends to spiral around in one place or else float around aimlessly. Normally, it's impossible for this core to re-anchor itself, and it inevitably drifts off into space at some point or another. However, in rare cases, with an incredibly high amount of magic (yes, I'm talking about using magic to anchor magic) it is possible to connect the core to another object. This connection tends to be weaker than a naturally-formed one, and can fairly easily be broken.