If it's not an Apple Magic Keyboard then it is a 3rd party device and you should check with the vendor if they have any updates, etc. For example, Logitech has their dongle and some models also support Bluetooth. Logitech software typically updates the firmware of their devices paired to the dongle. Despite bluetooth not needing the dongle the keyboard itself might need a firmware update to handle power sleep / wake of the keyboard itself. Other keyboard brands may have their own software that may need to be updated.
Apple is very close to releasing macOS 15.1 so keep checking for updates.
As a workaround, most bluetooth keyboards will connect using a USB charging cable (Lightning cable for Apple Magic devices) that defeats it being wireless but at least the keyboard will work reliably until the bluetooth issue is resolved.