Simply put it is the command that you are running itself that determines the transistor states and therefore the logic gates in use. It will see a series of bytes and that series are effectively configuring the processor initial state. It's a lot more complicated on modern processors with multiple execution units but this is the gist of it.
When the processor starts up it will be at address 0, and will put that address onto the address bus. It will then be waiting for the bytes at address 0 to appear on its data inputs. This will then tell the processor the starting state it needs to be in, so it can then put the next address location out on the address bus and wait for the next byte and so on.
Soon it will have a full command, and the bytes it needs to multiply together. All these bytes will effectively "configure" the processor core to the task that needs to be done.
Having pulled the full command in along with the needed data bytes put in the register it can then carry on with the command needed and, after cycling through the series of logic transitions needed, will then output the result.