I have had similar problem in the past and the reason was a device connected to another HDMI TV input. It was a Sony PS2 console with an HDMI converter that was damaged. It seems that the damaged converter interfered with the HDMI bus and this avoids to correctly detect the CEC.
Try to connect only your Pi4 to the TV and disconnect any other device on the others HDMI inputs.