I know this is an old thread. I'm gonna reply anyway hoping that it would be helpful to someone. I had the same problem with Mac Mini M1 with both my magic track pad and magic mouse. It kept disconnecting few times every minute. I had to use the magic trackpad plugged in because it got so annoying. I tried bluetooth reset and usb disconnecting and all the other suggestions you can find in here.
Finally, I remembered something apple support person told me. she said that it can be my monitor. Weird ryt? I didn't believe her at the moment. Anyway, I bought a USB-C hub with an HDMI connection and moved my monitor to that.... all the bluetooth issues are SOLVED now. no more bluetooth connection issues. I guess I'm buying a thunderbolt monitor.
Here's the summary for the people who doesn't like to read,
1. It's your HDMI monitor
2. Buy a USB-C hub with a HDMI port
3. Move your monitor to the HDMI port on the hub
Try this if everything else fails.