You’re right that SW4 has the lowest MAC, but MAC only breaks ties when priorities are equal. In the exhibit, SW2’s STP priority is 4096, which is lower than the others' priorities. Since STP compares bridge priority first, SW2 wins and becomes the root.