If the supplies are not connected at all, then you can't mix the voltages. For instance, you can't have an Arduino measure mains voltage (even via a suitable voltage divider) and have the Arduino connected to ground.
In your case, the grounds of the two 5 V supplies and the 12 V supply are already the same point, so that is fine.
It is more difficult if you want to switch the positive, rather the negative that you are switching.
You can get a problem if one 5 V supply is there and the other isn't. That could lead to an input on the Arduino being at a higher voltage that its supply, or a high output on the Arduino trying to power what is effectively a short circuit.
A fault on one 5 V supply, or even different turn-on and turn-off rates can lead to problems.