Sounds (if you’ll forgive the pun) like there is a CEC issue somewhere, with either the TV’s CEC computer not recognizing the signal from the Beam, or the Beam not always sending the CEC recognition signal properly.
I would check both the TV and your Sonos controller for any updates, and apply them. After that, I would unplug both from the wall for two minutes. Then plug in the TV first, wait two more minutes, then plug in the Sonos.
If the problem continues, I would recommend that you submit a system diagnostic within 10 minutes of reproducing the issue, and call Sonos Support to discuss it. Don’t post the resulting diagnostic number here.
There may be information included in the diagnostic that will help Sonos pinpoint the issue and help you find a solution.
When you speak directly to the Support staff, they have tools at their disposal that will allow them to give you advice specific to your network and Sonos system.