Not all commands are evaluated immediately. Otherwise, /set would never be able to get the variable name.