I'm going to start with your specific question:
Did Sony and Panasonic stop making DSLRs because they were of poorer quality, and were therefore less profitable?
Flat-out no. Both of these companies made top-notch, well-received and well reviewed DSLRs. However, it's a very competitive and harsh market, and both companies decided to not fight over third or fourth place as DSLR makers and instead to focus on mirrorless cameras, which they both make today. Other companies, like Samsung, decided to leave off making interchangeable lens cameras entirely — again even though their cameras were well-reviewed.
If we're primarily using DSLRs as the example, twenty years ago is too far to go back, because the breakthrough consumer-priced DSLRs didn't arrive until after the turn of the millennium. But let's look at some reviews from fifteen years ago, in 2002 and 2003:
Only Olympus gets less than highly recommended, but the review is still positive overall, and by 2005 the Olympus E-500 EVOLT also achieved the "highly recommended" designation.
Sony and Panasonic aren't on this list because they didn't make DSLRs 15 years ago, let alone 20 — they both entered the market in 2006 with the "highly recommended" Sony Alpha DSLR-A100 and "recommended" Panasonic Lumix DMC-L1. I think that it's most likely that it's this late entry to the market that made the biggest difference, not something fundamental in quality. They decided they'd instead move to the mirrorless area, where Canon and Nikon still don't have particularly compelling options.
You offer the hypothesis that Panasonic and Sony backed off of photography because they're primarily electronics companies rather than camera companies. I think this isn't the case for two reasons. First, they haven't backed off of photography at all — they've simply backed off of one camera technology branch but make very serious offerings on another. Second, Fujifilm and Olympus are both camera companies that used to offer DSLRs but have also taken this path. I think that suggests the issue is market-related, not something to do with the companies themselves.
Sigma is on your list as currently making DSLRs, which I guess is technically true, since you can buy an SD1 Merrill new, but that camera was introduced in 2012 and hasn't been updated — Sigma too has really decided to focus on mirrorless.
In general all of the big brand camera makers made and make excellent cameras, although the state of the art twenty years ago was far behind what it is now and none of the offerings would live up to what we expect from a budget entry-level consumer camera today. I don't think, though, that any left the market because they couldn't keep up with technology. It's true that especially during those early rush years of digital cameras it was sometimes the case that Nikon's newest offerings outclassed Canon, or vice versa, or another company, but it's never been a landslide sort of thing nor something where there's been a permanent advantage.
That said, there's something to be said for sticking to one of the recognizable brands, whether the big-two Canon or Nikon; general electronics giants like Sony, Panasonic, or Samsung; or one of the smaller but legitimate camera companies like Fujifilm, Olympus, Pentax, or Sigma. This isn't a risk for DSLRs, but for compact cameras twenty years ago, you definitely could go wrong buying a $100 generic digicam from Sakar or other companies that specialize in cheap generic Chinese-import electronics.