Just to weigh in that I have been having the same issue. I have an M1 iMac that is less than a year old and a Magic Keyboard with Numeric Keypad and Touch ID that I bought in May 2022.
The Touch ID has worked flawlessly from day one ... right up until about two weeks ago when it just would not work. I tried all of the fixes on Apple's support page (including, of course, making sure the OS is up-to-date) and eventually broke down and called tech support. They determined that something was wrong with the Touch ID sensor itself and sent out a new keyboard.
The new keyboard arrived, I turned it on, and it immediately worked flawlessly ... until I sat down last night at the computer and it wouldn't work. The keyboard itself works, so I was able to log on. I navigated in the Settings to Touch ID, and everything was shown as "on", but when I tried to add a fingerprint, it wouldn't recognize it. So I turned off the keyboard, plugged in the cable, turned it back on, and got it working again.
Apparently I left the keyboard plugged in overnight, so before I woke it, I unplugged the keyboard and ... the Touch ID sensor would not work. This time, rather than logging in and going to Settings, I turned off the keyboard, waited a few seconds, and turned it back on. Touch ID still did not work, but when I went to Settings again, it was able to capture another fingerprint. So I pressed the Touch ID button to put it to sleep, then tried the Touch ID again ... and it worked.
Point being: This is not a hardware issue, since this is a brand new keyboard. Something seems out of whack in the operating system, would be my guess.