It looks to me like the first FOR is processing the output of the command
Code:
"prompt #$H#$E# & echo on & for %%b in (1) do rem"
Maybe I get it now. Because that command turns ECHO ON, the output of that command is (would be) the (new) prompt followed by the "rem". That would be #<backspace>#<esc>#rem and the outer FOR sets the variable ESC to the second token.
The surprising part is that the prompt itself is part of the (would-be) output of "prompt #$H#$E# & echo on & for %%b in (1) do rem".
[And maybe not.]