From soaring energy costs to shifting voter demographics, multiple critical factors combined to break the ruling party's electoral hold