The main problem with hydrogen is distribution. You'd have to build pipelines to a lot of train terminals to refuel the trains. So it seems to me running overhead wires for electric trains would be the better options for most cases. Yeah it's a century old technology there's nothing sexy about it, but since it's old tech it's well tested and will be reliable. The thing with technology is that you usually have to have a transitional phase that's viable. Many "diesel" trains actually have electric motors that drive the wheels, they just haul around a diesel generator to power those electric motors. So you could use the overhead wires where available and run the diesel generators on parts of the track that don't have that in place yet while transitioning. Then when there's complete electric coverage, do away with the diesel generators entirely.
I think hydrogen for ships makes sense because a port could have a hydrogen terminal similar to present day LNG terminals. LNG is transported by ship so hydrogen could also be transported to the terminals similarly. Eventually hydrogen pipelines can be built from there, but pipelines take time to build.