Aren't all animals 'electric', like galvanic muscle twitching? Didn't these fish just repurpose existing electrical infrastructure for a different use?
It's well established nowadays that a gene duplication occurred in the ancestor of all bony fish. That's sometimes a problem for people doing gene knock-out experiments on zebra fish, where you sometimes knock out not only the target but also the homolog because the two are still too similar, despite 425 Myr of evolution.
Land vertebrates do not have this duplication because they are descended from an ancestor of the coelacanth.
What happened with these fish is that they repurposed the backup. They had two Na channel genes, one in muscles, and one spare.