Because the scope in which it is needed it necessarily must be declared, whereas where not needed it's potentially likely an irrelevant variable. The answer to this lies in the question: why would you just leave things lying around in places they have nothing to do with? You generally don't, I hope - at least not since you were a teenager.
Consider all the clothes on the floor back in the day, no one mom knowing which was clean and which dirty. Does she wash them all, or leave them all, or what? So it is with memory management in such technologies. What's being used? What can I move around? What can I dispose of? etc.
Maintaining clean scopes and suchlike in these cases has a number of benefits, other than this just being a natural thing to do. Pieces of code in scope can be seen as 'units of work' in some case, and it can also protect from data conflicts if a variable (name+type) is reused.