Polls leading up to the election had it being a close race with a slight edge to the party in office. Shortly after the incident, the admin began suggesting that this was not Islamic terrorism, but it quickly became clear they were talking out of their arse. A small percentage got skittish and it ended up being a close election with the slight edge going to the opposition party.
It does appear that when the race was so close, a little skittishness and a shift of a relatively small part of the electorate shifted the election. Same thing could happen here, of course, but it's inaccurate to say that nobody thought Zapotero had any chance of winning. It was close in the polls and a close election.
You left out the Socialist rioting on the night before the elections and the blockading of polling places in conservative areas by bunches of Socialist/anarchist thugs attempting successfully to dissuade voters perceived as likely to vote PP.
Also, it was initially reasonable to suspect ETA, because an identical van to the one used by the Muslims, stolen in the same city in Asturias, with an identical load of explosives meant for divvying up into the knapsacks, had been stopped just a couple of days before the attack. The drivers were ETA members; unfortunately, the other van, which was driven by the Muslims who were eventually apprehended, was stopped but not searched. Believe it or not, the police just cited the driver for having a stolen license plate and let him continue on his way.