We're not talking about accidentally inventing a machine gun, we're talking about being cautioned about inventing a machine gun and not caring:
"Hey you're inventing a machine gun!"
"No I'm not, and even if I was, machine guns can be used for many things other than violence!"
Edit: Also, Einstein in this analogy is the one cautioning about someone being able to invent a machine gun.