shoots in a flat trajectory
Lol what? That's physically impossible, the projectile absolutely follows a ballistic tragectory like any other gun. A 20MJ railgun has a range of 93km, which is much farther than the horizon.
No, that's not the reason the railgun was not completed. It can only be used by specialized ships, and cannot be fired many times before extensive maintenance is required. It's too expensive to sustain. They also realized that they could get some benefit from using the more effective high velocity projectiles with conventional guns, anyway.