Tanzania’s electoral commission declared on Saturday that President Samia Suluhu Hassan had won, with nearly 98% of the votes, an election that set off violent protests across the country this week.