Let's not forget that Mattis chose to carry water for a lot of grubby, unethical, destructive and downright cruel stuff for Trump. His resignation letter a strong defense of NATO, but far too late. 3,000 troops in Syria was his breaking pt, not shooting at refugees in Mexico.
Or it was the last of the things he was trying to actively prevent. Once he lost on all his battle fronts, there wasn't a point in staying. IOW, if the order had been different, it might still have happened.