Do you know what specific condition causes the keyboard not to be recognized?
Another user reported that they would attach the keyboard while the computer was asleep and it wouldn’t be recognized when the computer was woken up. I think this is normal behavior as the computer won’t recognize any connection changes when it’s asleep. Removing and reconnecting the keyboard after the computer was active again would solve the problem.
If your keyboard hasn’t been detached and still isn’t recognized sometimes then it definitely sounds like a problem and, as you mentioned, could be your computer as you’ve already replaced the keyboard.
I have had a few Surface Pros over the years and have run into this problem on occasion but it has been pretty rare. If it’s happening with some frequency, then something definitely isn’t right.