Alright so, I made some changes to my laptop and from past two days I haven't had any issue of the keyboard/trackpad not responding problem and I believe it might fix your problems as well.
So, the problem I was facing was because I had two WiFi network with the same SSID (wifi name) and this was causing a problem. What does this mean?
Say my original router has properties 'A' and Wifi name 'MyWifi' with password as 'MyPass'. Now I have another router which has properties 'B' and wifi name 'MyWifi' and password as 'MyPass'.
As you can see I have two different routers but they have the same name and password. I did this deliberately so that I can have a seamless connection when I switch routers from one place to another and it reduced the burden of remembering two wifi names and passwords; and for me, here lied the problem.
For some reason, I believe that it's related to keychain saving wifi information or some other mechanism saving the wifi state and info when we put the laptop into sleep. When we wake it up, it has a hard time recognising which network it is because it finds two entries of the same name in the system and hence the freeze.
This also explains why the freeze are very random. For some people it just happens for a few seconds and while for some, you need to restart the computer. It also explains why some people are having this issue with old MacBooks from 2012 to the latest MacBooks also.
So what's the solution?
Nothing. Next time when you encounter this issue, just change the connected router name and password and reconnect it and hopefully it should be fine. Just make sure you change the name cause that's important.
I did some extra steps which might be helpful for some folks.
Go to Settings->Network.
Click on WiFi and delete the interface with the minus button on the bottom left
Click on the plus icon right next to it and the select interface as wifi and name wifi
Click Apply
Restart
Pls do let me know if it is helpful as I haven't encountered this issue once after renaming the network name.
The explanation and reasoning given above is just my hunch and it might or might not work for you.
This worked for MacBook Pro 15' mid 2018 i7 16GB 1TB 560x running Catalina 10.15.6