Had the exact same problem.... now solved. The information herein might help others with troubleshooting.
I have an M4 Pro Mac mini and an Apple Studio Display. Have 2 Apple keyboards. One about 7 years old (Bluetooth) and another about 13 years old (Model A1243). Both have the numeric keypad. The older one has a USB-A connector.
I prefer the older Model A1243 just for the feel of the keys. But it would work intermittently when plugged directly into the Mac mini or the studio display (used Anker adapters). The front ports on the Mac mini worked best, but still were intermittent. Very frustrating.
Also have an OWC Thunderbolt-4 dock. Eventually plugged the dock into the Mac mini. This dock has a USB type-A port. This dock also comes with optional software for ejecting disks connected. But per OWC:
"When you install this app, a driver is also included for the dock’s high-power USB ports. The driver enables use of the Apple SuperDrive and USB Keyboard on these ports, and should enable them to charge 1st, 2nd, and 3rd generation iPads as well."
Installed the dock driver and plugged the old USB keyboard into the Type-A port of the dock. The keyboard works perfectly! I've been using it for a couple of weeks.
So.... I am wondering if the issue has something to do with the power (or voltage?) being provided through the new generation USC-C and/or Thunderbolt ports for old USB devices. Note that OWC dock has its own power supply.
Anyway, hope this info helps.