local() essentially replaces the current variable (package variable - or aggregate element) with another variable, until the runtime exits the scope the local() is in.
If no magic is involved, it may be easier to think of it as temporary replacing the value.