I can confirm that this is related to WiFi configuration.
I recently, 2 months back got my top case replaced because of a dead battery out of the box. After that I started experiencing this issue. Randomly it occurs where the keyboard and trackpad is not recognised.
I thought it was a faulty replacement from the service centre but then going through the comments here, it turns out to be very common issue. So I can affirm that its not an hardware issue at all.
I did a test where I just downgraded to Mojave and the issue still persisted. This also justifies some users having the same issue for different versions of MacOS as seen in previous posts. So I'm pretty sure this is a legacy bug which apple never responded to.
As to how I affirmed its a bug related to wifi, I too have shifted to my native due to current pandemic and I am using a dedicated SIM activated hotspot which acts like a router. It stays active all the time and my mpb is connected to it always. I suffered keyboard/trackpad freeze only with this network and never ever I had this issue with my original home router.
So apple has screwed up big time.
I will try to pin point the exact issue by comparing the configurations of these two networks. Hope a specific config can resolve our issue.
Buy a $2000+ laptop and debug problems yourself. Look how the turntables.