12V or 24V switch circuit
Use a SPDT Relay. Attach the coil to the incoming 12volts. Coil rating needs to be 12v of course. NC contact connects to 24v. NO contact to 12v. Contact pole (aka common) output to your load.