I think what some people at perhaps missing or underestimating, is that the LibDems were campaigning extremely actively.
Chesham and Amersham has been such a safe seat for so long, that during normal elections all of the parties focus their resources elsewhere, and beyond a few minor leaflet drops (mainly the free ones) there is normally no campaign to speak of whatsoever.
In this by-election on the other hand, for the first time in literally decades, there was an actual campaign with extremely active canvassing going on, especially from the LibDems
The tories appear to have realised this a little late, and their campaigning was much less effective in comparison. But the fact that so many voters were doorstepped by the LibDems (I think they claim to have spoken to half of the electorate), and engaged in a political conversation in many cases for the first time, had a huge impact on the final result.
Many, who had voted for the tories by inertia for decades were persuaded to reconsider through these conversations. Likewise those that had previously voted Labour, having seen the basically non-existent Labour campaign, could be persuaded that only the LibDems had a chance of winning.
The lib dems achieved this by engaging their activists from all over the country, since they did not have their own campaigns to deal with. The big question now, is whether the inertia from this election will be enough to allow the LibDems to hold the seat at the next General election, where resources will be spread more thinly.
On the other hand, given the LibDems have now managed to win it, they will invest significantly more resources into holding it in future - and the tories will invest resources into trying to win it back, meaning the days of nobody bothering to really campaign are gone for at least a few election cycles to come.