Then, after the Arab Spring uprisings in the Middle East and series of demonstrations urging clean and fair elections in Kuala Lumpur, Mr. Najib switched tack, liberalizing parts of the economy and freeing up civil liberties, including making it easier for protesters to take to the streets, apparently helping him in Sunday's contest.