I have a quite similar issue on Sonoma, however it only seems to affect charging via USB-C Hub.
It started recently and I don't quite understand what is going on as this has been working well for over a year. Maybe the Laptop is already getting old? (M1 Air)
So it usually charges fine but sometimes it just stops charging all together and the battery percentage starts depleting.
Unplugging the USB hub and reconnecting it tends to show the message that it's on a "power adapter but not charging" or something similar.
I have got it working almost every time by restarting the computer and switching the low power mode ON and OFF. It takes like half a minute and then it starts charging again.
I was thinking that perhaps it had something to do with overheating protection since I run quite heavy AI workloads on the machine and it gets quite warm.
But I don't think that's really the case, because if I plug in the charger straight into the MacBook instead of via the USB hub, then it will charge normally.
If it was an overheat protection then I don't think it would make any difference how I tried to charge the machine.
It could be that something has happened to the USB hub and that it's not faulty. But then it's strange that I can temporarily fix the issue by rebooting the Mac and mess with the power settings.
And given that these issues started recently after upgrading to Sonoma it makes you wonder...
My battery health is reported as normal sitting at 89%
I am currently thinking about how to move away from the USB hub.
I want to be able to connect a USB-C SSD, an external display and still be able to charge the laptop.