As with most food history a lot of this is debated. One version is that the British encountered a fermented fish sauce somewhere in Asia and transliterated the name as ketchup. They then liked it, and tried to reverse engineer it with what was available at home and what they remembered of the taste. Ketchup shows up in the Oxford English Dictionary in 1682.
The English bring their recipes to the United States, and their descendants make mushroom ketchups, but also walnut ketchups, oyster ketchups, and all sorts of things. As late as 1913 Webster defines ketchup listing mushroom first, then tomato, then walnut.
Tomato ketchup becomes dominant in the early 20th century through the events described in this article, which not only destroyed most of Heinz’s tomato competition but all the other ketchups too.
There are also other, more modern ketchups. A personal favorite is Filipino banana ketchup, which was developed when that country was cut off from tomatoes during WWII.