Could a very accomplished witch/wizard cast any number of spells or charms to give a muggle some amount of magical powers? Could it be even theoretically possible?
TL;DR version: The magical gene is passed on from generation to generation; in purebloods it will always be passed on in full or as a Squib; if it is produced in a Squib, then that Squib's great-great-great x4 grandchildren will randomly get the magical gene. As a result, even Muggleborns are distantly related to Purebloods.
In the Deathly Hallows, it is explicitly stated that magic cannot be transferred or created within a person who was born without the magic 'gene', as it were:
“But how are they supposed to have ‘stolen’ magic?” said Ron. “It’s mental, if you could steal magic there wouldn’t be any Squibs, would there?”
“I know,” said Lupin. “Nevertheless, unless you can prove that you have at least one close Wizarding relative, you are now deemed to have obtained your magical power illegally and must suffer the punishment.”
- Deathly Hallows, The Bribe, page 209 -
Following the rules of genetic inheritance, we can ascertain that this is a likely sequence for the passing of the 'gene' for magic (please note, there is a minor error - Halfblood Traibortina is actually a Muggleborn):
Where pink is a pureblood wizard (dominant magic gene, for example MM);
Where blue box with black text is a Squib carrier (a mutated magical or Squib gene, for example Ss);
Where blue box with gray text is a Squib/Muggle (a hidden mutated magical gene) and;
Where pink box with gray text is a Muggleborn wizard (with a dominant mutated magical gene, producing SS and;
Where white box is a half-blood wizard.
This doesn't line up perfectly (or at all, really) with genetic rules, but we can see that magic recedes and dominates over generations - much like blood types.
In this example, Sorceress and Wizard Traiborn both are purebloods, and produce two pureblood children, but owing to a mutation, produce a third squib child.
This squib has the magical gene, but it will surface randomly over many generations. The squib marries a Muggle, and they create a prospering Muggle dynasty.
Meanwhile, Wizard Traiborn Jr marries Sorceress Bobby, and as they are both purebloods, produce only pureblood children.
Several dozen generations pass.
Randomly and inexplicably, the magic gene "resurfaces" in Muggleborn Traibornet.