Let's look to the POSIX specification to understand why this behaves as it does, not just in bash but in any compliant shell:
2.10.2, Shell Grammar Rules
From rule 7(b), covering cases where an assignment precedes a simple command:
If all the characters preceding '=' form a valid name (see the Base Definitions volume of IEEE Std 1003.1-2001, Section 3.230, Name), the token ASSIGNMENT_WORD shall be returned. (Quoted characters cannot participate in forming a valid name.)
[...]
Assignment to the NAME shall occur as specified in Simple Commands.
Thus, parsing this assignment is required for a POSIX-compliant shell.
2.9.1, Simple Commands
Redirections shall be performed as described in Redirection.
Each variable assignment shall be expanded for tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal prior to assigning the value.
[...]
If no command name results, variable assignments shall affect the current execution environment. Otherwise, the variable assignments shall be exported for the execution environment of the command and shall not affect the current execution environment (except for special built-ins). If any of the variable assignments attempt to assign a value to a read-only variable, a variable assignment error shall occur. See Consequences of Shell Errors for the consequences of these errors.
Thus: An assignment given in part of the prefix to a simple command must be exported, and must not impact the "current shell environment", unless the command being invoked is a special built-in. Moreover, these steps shall follow redirections, which by nature must occur late in the command invocation process.
2.12, Shell Execution Environment
Utilities other than the special built-ins (see Special Built-In Utilities) shall be invoked in a separate environment that consists of the following. The initial value of these objects shall be the same as that for the parent shell, except as noted below.
[...]
Variables with the export attribute, along with those explicitly exported for the duration of the command, shall be passed to the utility environment variables
Thus: These variables are expanded by the subshell after fork and before exec'ing the command being invoked, and must -- by specification -- impact the child's environment alone.
Now, for some different behavior:
SOMEVAR=BBB sh -c 'echo "$SOMEVAR"'
... benefits from the sh
instance creating shell variables from its environment variables (as required in section 2.5.3 of the POSIX specification) on startup.
It's worth noting, by the way, that the syntax you're asking about is for assignment within a simple command, as opposed to assignment within a subshell. You can control assignment in a subshell involved in a pipeline like so:
{ SOMEVAR=BBB; echo "$SOMEVAR"; } | somecommand ...
...which puts the assignment into the subshell running the first component of the pipeline (if your shell is indeed running that component in a subshell, which is undefined behavior inasmuch as POSIX is concerned; from the spec: "as an extension, however, any or all commands in a pipeline may be executed in the current environment").