It could also check the cpu of the machine it's running the compiled code on, no?
Not if it's not present and running on said machine.
You probably mean that the compiler might produce code that checks the cpu. That's possible but until recently the cpu check was only used to create effective code, choosing the code most appropriate for that particular cpu. If the compiler is checking if there is an intel cpu in the mistaken assumption that that is required to run SSE2 then the mentioned trick could very well be effective.