The railgun is a precise weapon that strikes specific targets and so the users of it can exercise reasonable judgement on it's use. It's a requirement of various treaties on warfare, such as the Geneva Convention, that war fighters be accountable for their actions and not engage targets under specific circumstances, such as if they are civilians or surrendering.
Gas is an extremely unreliable and indiscriminate weapon that is highly likely to affect individuals beyond any reasonably intended target, including civilians. It's not possible to use it and still meet obligations under treaty, such as not engaging civilians and surrendering troops. Therefore it's use is not allowed and any use of it is accountable as a war crime.
One of the big differences is that gas chambers are only useful for killing prisoners while there is no indication whatsoever that railguns will be used to kill prisoners.
(That said, if it were my execution and the choice were given to me, I would of course chose the railgun! Suffocating on cyanide gas doesn't seem like much fun, I'd rather be vaporized by a hypersonic artillery shell, if it's all the same to you...)