When Pedro Sánchez, Spain’s socialist Prime Minister, called snap elections in October, he took a risky gamble. His government’s move to address the housing crisis through a ban on evictions and tighter regulation of lettings had been defeated in Parliament by the right-wing parties and the Catalan Junts party. Mr. Sanchez’s calculation was that his…