I bought my MacMini M1 when it was first released. I had read about BT issues and didn't have any problems for a couple months.
Then all of a sudden one day my Apple BT keyboard started acting weirdly. When I'd press a key to type one letter, a whole string of random letters would come out.
Fortunately, I was logged-in and was able to turn off BT and then when I turned it back on and everything connected, the keyboard was fine. This has now happened maybe 1/2 dozen times over the past 6+ months.
When I am at my login screen I can't turn off BT because the icon doesn't show up. So, when it has happened upon login, I grab my wired keyboard and login and then turn BT off/on and it seems to reset for weeks.
I'm fully up to date on OS updates, so clearly Apple hasn't solved the problem yet. I'm tempted to buy a Logitech keyboard with a small dongle sending unit, but I really like my Apple Keyboard so I'll suffer with it until they hopefully solve it.