“This puts a stake in the heart of the idea of an ancestor with a central nerve cord,” says Greg Wray, an evolutionary developmental biologist at Duke University in Durham, North Carolina. “That opens up a lot of questions we don’t have answers to — like, if central nerve cords evolved independently in different lineages, why do they have so many similarities?” Nature, 2017

It is generally assumed that bilaterians nerve cords evolve from a single Ancestral Nerve Cord but from Amy Maxmen at Nature:
Tiny sea creatures upend notion of how animals’ nervous systems evolved: Sweeping study of sea creatures suggests wild deviations over evolutionary time.
A study of some of the world’s most obscure marine life suggests that the central nervous system evolved independently several times — not just once, as previously thought.
The invertebrates in question belong to families scattered throughout the animal evolutionary tree, and they display a diversity of central nerve cord architectures. The creatures also activate genes involved with nervous system development in other, well-studied animals — but they often do it in non-neural ways, report the authors of the paper, published on 13 December in Nature. More.
Paper. (paywall) More info re paper.
Have the molecular mechanisms that are linked to the developmental organization of centralized nervous systems evolved once or multiple times? Evidence from nine animal species points to the latter.… Previous studies in acorn worms8 (hemichordates) and flatworms9 found no dorsal–ventral homeobox-gene expression in their trunk nervous systems. This absence was previously interpreted as a secondary loss of an ancestral neural patterning system. But in light of Martín-Durán and colleagues’ data, this condition could, in fact, reflect the ancestral nephrozoan state. It now seems that the ‘typical’ dorsoventral gene network was not deployed in the nervous system of the last common ancestor of bilaterians or nephrozoans. Rather, the developmental mechanisms that pattern the neural cords in mice, flies and P. dumerilii might have evolved convergently.
Martín-Durán and colleagues’ work paints a complex and nuanced picture of nervous-system evolution. Their data raise the possibility of multiple origins of animal nerve cords, and suggest that a suite of genes that pattern the dorsal–ventral axis has been repeatedly co-opted into nervous-system development. – Caroline B. Albertin &
Clifton W. RagsdaleMore.
Also, pdf of Maxmen on similar subject (2011).
They could have evolved by convergence. According to the Encyclopedia of Life, most animals are bilaterians:
Most animals, including vertebrates (fishes, frogs, birds, humans), arthropods (insects, spiders, crustaceans), and molluscs (snails, mussels, squid), are part of the group Bilateria. This name is derived from the fact that representatives generally show bilateral symmetry. A single median axis divides the body into equivalent halves that are mirror images of one another. These halves run from the front end, which is usually differentiated into a head, to the back end, often in the form of a tail. This body plan contrasts with that of radially symmetrical animals like jellyfish and sea anemones which have multiple similar parts arranged around a central axis, so their bodies lack a front and back end. More.
Convergence means that, instead of starting out from the fabled Common Ancestor, life forms or parts thereof arrived at the same destinations from multiple origins. That could support either design or structuralism (an underlying pattern, based on physics and chemistry, governs evolution) — but not Darwinism, the only form of evolution known to pop science, according to which it is all random.
See also: Evolution appears to converge on goals—but in Darwinian terms, is that possible?