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.