It's a lot more complex than that.
Some of the best-sounding albums I own on CD were originally recorded on analog media. Like for instance Boston's first album, or basically anything produced by Alan Parsons back in the Pink Floyd and The Alan Parsons Project days. They sound great on LP, they sound great on CD, they sound great as FLAC files on my PC. The reasons is that the people doing the recording, mixing and mastering knew exactly what they were doing. They knew the benefits and drawbacks of the whichever medium they were targeting, and tweaked the mixes, levels and equalizing to suit.
You simply cannot just throw a spot-on mix made for LP on a CD and expect anything but a mediocre result, and vice versa. The basic reason for this is a vinyl is honestly pretty crappy. Low frequencies a noisy because of the RIAA equalization needed, high frequencies roll off around 12-15kHz at the most. And that's before you get into the massive problems with dust, scratches and wear and tear. Thus the mastering needs to work around these issues, and by the time the the CD was coming onto the market, LP mastering was pretty damn good, so people just threw those same masters directly to CD, with mediocre results because the medium was completely different. Some techs even forgot to apply RIAA equalization to their masters, leading to extremely tinny and weak-sounding CD releases, creating the idiotic audiophile myth that all CDs sound bad "because they're digital". Absolute bullshit, a CD will give back exactly what you put into it, every damn time.
Vice versa, some modern LP releases have been lazily created from straight made-for-CD mixes, without compensating for the drawbacks of vinyl. The end result is a shitty, often severely overdriven and distorted sound. Luckily, some modern vinyl releases are seriously great. Blackwater Park by Opeth sounds amazing on vinyl, and there is a definite charm to peeling an LP out of its sleeve, putting it on the turntable, giving it a quick wipe with the carbon fiber brush and carefully dropping the needle into the groove yourself. Another example is Californication by RHCP, where the CD sounds like absolut shit due to the techs turning everything to 11 like a pack of shit-flinging monkeys, but the LP sounds great because you simply cannot overdrive an LP like that without destroying everything, so they were forced to make a better mix.
For some albums, I listen exclusively to good FLAC rips of the vinyl edition, because of the massive difference in mastering quality. Sure, the noise floor is much higher and there is some definite high-frequency roll-off, but I much prefer that to the "everything louder than everything else" approach that a lot of CDs have been mastered to. I could burn one of those vinyl FLAC rips to a CD and play it back to you on my inexpensive CD player, and your would swear I was playing an LP. Why they couldn't just put those well-crafted mixes on CD in the first place, I have no idea.