CDs are smaller than vinyl records, so that brings down shipping costs. From a consumer's perspective vinyl records require a lot of maintenance: needles need to be changed, records should be kept free from dust.
Cassettes are small, but complicated. I wouldn't be surprised if cassettes are more expensive to produce than compact discs. It is interesting that while CDs overtook cassette tapes in the 90's (aside from mixed tapes shared between friends), Laser Discs didn't become more popular than VHS until DVDs. Maybe the difference in visual quality wasn't worth the effort to switch media until televisions became larger larger and sharper.