I think you've discovered for yourself one of the design flaws of Mp3tag's scripting system.
I mentioned the same thing some time ago in the german section 'Mp3tag Forums > Mp3tag - Deutsch > Bugs' but did not receive any answer yet. Benutzerdefinierte Variable nicht sichtbar in Loop
I wish Florian to have some time to make this part of the scripting language more clear.