This is an example of folk etymology. The original word was Spanish cucaracha, but English speakers couldn’t make anything meaningful of that when they borrowed it into English, and so they folk etymologized it into cock “male chicken” and roach “a type of fish”, that sounds similar enough to cucaracha to be reasonable.
The same thing happened to Cayo Hueso “Bone Key” as “Key West”, for example.
Me plugging my monitor into my mobo instead of my graphics card for three years. I thought I had just gotten reeeeally unlucky in the silicon lottery.