Apple - Swap CMD and Alt only on external keyboard
There is a section dedicated to this under → System Preferences → Keyboard:
Open Modifier Keys… and reassign them from here:
These settings are specific to each external keyboard you have connected. They will “stick” between reboots, as well as whenever you unplug an external keyboard and plug back it in.
The built-in macOS solution did not work for me because there's no option to select a different keyboard.
For macOS Sierra to Mojave (current release as of right now), Karabiner-Elements does exactly this. You can find the GitHub page at https://github.com/tekezo/Karabiner-Elements.
It runs in the background. In the preferences, you configure the target device for modification and it remembers the settings. I have a bluetooth keyboard (Logitech G613) where only that keyboard's CMD and ALT are swapped. I use this keyboard between my PC and Mac.
Below you see an example of Karabiner-Elements v12. It doesn't show my G613 because it is not connected right now.