The rail gun works by electromotive force ....consider the "gun barrel" to have a top electric rail and a bottom electric rail.
The projectile is conductive (aluminum slug) ...so that electric current can flow from one rail to the other rail - through the slug. Very high current flowing also generates a magnetic field...and the projectile moves because of the magnetic forces. (Think of a motor ...the rails are the stator - stationary, the slug is the moving part - a rotor on a motor...) As the projectile exits the rails - the electric current breaks apart ....drawing a very humongous spark!
Think of the slug having a half-million amps flowing...and suddenly the electric circuit is interrupted/broken. One heck of an arc!
Makes sense. Thanks.