If you want to understand the past, look at the railways, writes the author of a new illustrated guide to British rail history