Just wanted to note - i was having the same problems after I got an RPi4 to replace an old RPi3B. They were both plugged into a Samsung LCD TV circa 2015 or so, and cec just wouldn't work with the RPi 4. I tried unplugging the TV for an hour, replugging power and the RPi4, but no joy.
In light of the cable advice above, I purchased an array of different quality (black) cables - including ones rated for 8k video and HDMI 2.1 etc., but switching out the cables didn't make a difference. When I ran cec-client -s -d 1 I could see the RPi4 was talking to the TV and able to see other connected devices, but the cec driver just wouldn't load completely, and so cec remained unusable.
FIX: I also had a firestickHD connected to one of the three HDMI ports. We never use it, so I didn't think to unplug it. I finally got around to unplugging that and then unplugging power to the TV, then powering up the TV with only the RPi 4 installed... and cec on the RPi4 immediately worked. I went back and tried the white Raspberry Pi official micro-HDMI cable and it worked fine too. I then reinstalled the FirestickHD and now everything is working together.
So, before you purchase a new cable, try unplugging all devices connected to any HDMI port on the TV (and probably any intermediate devices, like a stereo receiver), then unplug power to everything you're going to connect back up, and then power the TV, plug the RPi4 into your desired HDMI port, and then power the Pi. You should be good to go, but test it first, and replug all the other HDMI devices only after cec is working.