For instance, at 250 Wh/kg, you could get ~25MWh in a rail car weight envelope. If a typical train hauls 3000 tons of freight 500 mi on 3000 gallons of diesel, if the diesel to electric conversion efficiency is 50%, it means it takes 60MWh of electric energy to complete that journey. You could add 3 cars packed with batteries to accomplish that, and swap them for 3 charged cars to continue the journey, with those batteries being ~10% of the weight of the train. Put another way, a ton of batteries can move itself about 6000 miles on the energy it can store.
Such a battery car would be pricey ($2.5M cost of batteries at $100/kWh) but if a railway could charge and discharge such a car once every 2 days, it would have a pretty decent payback of under 5 years (depending on cost of power, charging infrastructure, and the fuel it is displacing). Hydrogen will always have to contend with batteries as batteries are 2.5x more efficient kWh in to kWh out. Hydrogen is hoping to be able to capitalize on nearly-free power due to renewables oversupply, but a battery rail car could be just as ready to take advantage of free power to recharge. Hydrogen only wins for longer term storage or applications where weight is critical.