In MS SQL Server Management Studio 2005, running this code
EXEC(\'SELECT * FROM employees WHERE employeeID = \' + CAST(3 AS VARCHAR))
gives
The documentation states that EXEC can take either a string variable, a constant T-SQL string, or combinations/concatenations of both of them.
EXEC
Your "why does this work" example uses a concatenation of a constant T-SQL string and a string variable, and so is perfectly legal.