I wouldn't call the Sega CD a colossal failure. It had a decentish number of games several of which were very, very good. Compared to the Duo in the US it was the CD system to own (I loved my TG-CD though.) Sega made bigger cartridges as well, but it was simply not as powerful as the SNES, and they were reaching the end of their console being able to in any way compete on graphics.
It's also amazing considering how well the system started out sales wise, with only 4 titles. Sega actually couldn't keep up with the demand for the thing. But that wasn't the problem.
The issue of the 32X is really all about the bickering between SoJ and SoA. Essentially Tom Kalinske thought that the 32X would be a good way to extend the life of the Genesis by a couple of years to allow enough time for the Saturn to get a foothold. SoJ thought that the Saturn would be their be all end all system. Each side of Sega was mistaken, but they were looking at their side of the pond. In the US the Genesis was hugely successful, and Sega was making a ton of money selling cartridges. In Japan, the Mega Drive was a distant third place, and the Japanese execs wanted it gone as soon as possible.
Kalinske also thought that there would be more time between the launch of the 32X and the launch of the Saturn in the US. The Saturn had already launched in Japan when the 32X launched, and it was a much superior system, in the US though there was supposed to be roughly a year in between the release of the 32X and the Saturn. However, when Sega of Japan saw their first real success in their home territory, they wanted it out in the US before the market here was ready for it. So instead of launching in Fall of '95 they launched in May of that year, 6 months after the 32X launch. At $399 the system was too expensive and didn't have enough games ready, third parties who were readying for the US launch were annoyed, and retailers who weren't part of Sega's early launch of the Saturn were pissed too. Even though initial sales of the 32X were strong in the US (500,000 in the first month or so) SoJ wanted the thing gone, along with the Genesis too. So it was
Looking back the 32X reminds me of a less successful Kinect, something brought out to keep an aging system fresh while we waited for the next gen. Honestly had it come out a year earlier it might have had a modicum of success. Launched when it was, and killed as quickly as it was, the system, which let's be honest was still going to have issues, was doomed to failure.
Of course Sega's hard core early adopters were pissed, and Sega's brand which had taken some lumps already, was pretty much in the shitter. When the Saturn failed in the US, the writing was already on the wall that the company was gonna die, just no one knew it at the time.
I always kind of wonder what might of happened in the US and Japanese branches never got into their dick-measuring contest though. We might even still have a Sega console today.