F-35s are not a replacement for F-18s. Two completely different planes. Two completely different roles. Because this system uses too much electricity (almost equivalent to the entire small city’s consuming level) and takes a long time recharging it’s power back to reload. Also after it fired shells every few times, it’s parts must be replaced because the parts are worn out by the strong magnetic field.
The railgun is a non-mobile weapon with an extremely limited ability to adapt to a changing battlefield.