There are two things that influence symbol lookup:
$Context. This is described in:
$ContextPath controls where the system looks for existing symbols. This search is done first.
$Context controls where new symbols are created if a name was not found in
$ContextPath any contexts.
Begin changes only
BeginPackage changes both
You are only using
Begin, but not
BeginPackage. This means that
$Context will be set to
$ContextPath will stay what it was before.
When you mention a symbol name such as
f, the first thing Mathematica does is that it looks for it in the contexts contained in
$ContextPath. If it is found there, it uses that instance. This is what happens during the second evaluation:
f is found in
f now refers to
f exist in
Global`? Because you mentioned it when evaluating
f. Note the distinction between the fact that a symbol exists and that a symbol has associated definitions. Just evaluating
sym alone will create that symbol.