Costs come down. Also you build up a workforce with experience, reliable chains of supply, partnerships...
And electrification is not a special case. The same principles apply across the piece, whether the investment is in track, signalling or trains.
The reason we have the stop/start, feast/famine approach to investment in rail is that decision making is constrained by the 4/5 year political cycle. There is no political consensus, even about what level of continuous public investment in rail is appropriate, let alone the priorities. Until we do have that political consensus (and I am not holding my breath) we are unfortunately doomed to have these cost and time overruns during times of feast and be left to ruminate on what might have been during times of inevitable famine.