There is nothing wrong with diesel per se, it is just that our current taxation and subsidy systems mean that it's used in extremely inappropriate circumstances. Cars have one single emissions or taxation rating regardless of what they're used for, even though they're more optimal for one use than another. If you spend all day driving up and down motorways with your engine at the optimum temperature then the fuel efficiency benefits of a diesel massively outweigh its NOx emissions issues. If you drive a diesel in a city for short distances in stop-start traffic then it's the other way around. For some uses in cities, the benefits of diesels are strong enough that it's worthwhile to fit the expensive emissions scrubbing systems that make them somewhat less damaging to the environment. The recent car scandal has revolved primarily around small engines which were claimed not to need these systems.
Trains are pretty much ideal for diesel because the engines are used basically all day, every day, and they're in a totally controlled environment where it's not possible to evade the necessary legal requirements. Your casual 'man in a white van' might be tempted by the idea of not keeping the diesel engine systems totally legal (e.g. DFP removal) as they're unlikely to be caught. If a train operator did that to their trains, they would get in some pretty serious legal troubles that they wouldn't be able to escape.
The other factor is that we haven't yet worked out a realistic alternative to diesel other than electrification, mostly because we've never been forced to. Being a closed system it is somewhat easier to explore alternative fuels such as CNG, LPG or hydrogen than for road vehicles, but these are still more appropriate on segregated branch lines rather than on long mainline services. Powering the Class 80x trains with alternative fuels would require making changes up and down the country from Inverness and Aberdeen to Penzance.
Batteries are showing promise but it remains to be seen just how applicable they are to trains. It is comparatively easy to provide mains power to trains as they only go in predictable lines and the metal rails and wheels provide a return conductor, so you can have a simple pantograph and single conductor arrangement for power (compared to a two-pole trolley bus). While batteries will be able to take on basically every duty on the road, there will be a tipping point on the track where standard electrification will just be a better idea. Where that point is, we don't seem to yet know. I'm firmly of the opinion that it won't be as high as other people think, so we'll be seeing a lot more electrification in future.