Hello
after so many tries to fix it, by deleting drivers, enabling disabling the Sony drivers, reboots (not Win11 re-installation) i finally found it and partially fix it.
On my laptop i have Realtek audio drivers (driver version: 10.0.22621.1) and every time the XM4s were connected but not as audio output, this started happening the last 6-7 months. It was driving me crazy.
So, one more time started to try and fix it, i went to the old control panel, i disabled all the playback and recording devices, went back to Win 11 settings deleted the XM4, then i went to system > sound > add device > Bluetooth device, it took about 5-10 after the XM4s were connected to show them as an actual output device.. After that i enabled back the playback and recording devices back from the old control panel and so far all look good.
However, after powering off the XM4 and tried to use them again as an audio output device with Realtek active, again i went to same issue. I disabled all the playback and recording devices again from the control panel but still the XM4 do not appear as audio device. I saw in the control panel > audio > playback the XM4 were appearing and disappearing after reconnecting. I start digging into the device manager since it looked like a conflict of drivers. In the System devices i found a Sony hand free drivers, i disabled them and it asked me to make a reboot (interesting!). So after the reboot, i start again removing the XM4 drivers from the Win11 Bluetooth settings, i disabled again the playback and recording devices in control panel and started again to make them to work as audio output device. After many tries i came to the point that with the Sony hands free drivers disabled and the MS microphone array disabled it looks to be stable as an audio device. I still have to click from the Bluetooth devices the connect button after i d/c and reconnect the headphones but at least i can use them now as audio output device (microphone is not working because of the hand free drivers that are disabled).
So long story short, it looks that the Sony hand free drivers with the Microsoft microphone array driver AND the Realtek audio drivers have some sort of conflict between them.
Since Win11 is the Operating System, i would suggest some MS devs to have a look where the conflict lies in and contact either Sony or Realtek to fix their drivers. The Sony XM4 are very popular headphones and the Realtek audio chips are very common in laptops.