In the extreme case, a railway which is 200 miles long and takes 3 trains a day will never have a positive financial case for electrification. So once you've electrified all the stuff that should have been done decades ago (like main lines with 10 trains an hour) and then pushed on to the marginal stuff (hourly rural lines) there's still a small core of lines left. You could just bite the bullet and electrify them anyway, or you could go with things like battery electric trains (good for short distances off an electric mainline) or biodiesel/green hydrogen. The latter are likely to be cheaper.