It's almost like B4a is trying to do what you wanted to do, rather than what you actually told it to do. Bear in mind that there is no standard constraining the design of BASIC dialects, and I am quite happy that B4A defaults to the BASIC tradition of taking reasonable default actions rather than unnecessary bombouts
Mind you, there's stuff I'm not so keen on too, compared to the way traditional BASICs do stuff, but generally those are the result of B4A being built upon Java.
It's a scope thing! B4X only has two scopes, global and local. All variables within a Sub, wherever they are declared, are local and visible to all code within the Sub. This is unlike Java, C++ or C#, for example, where variables can have block scoping within inner code blocks.