A late right-wing shift, a banking scandal and economic frustration may be behind Bolsonaro's last-minute gains.