After a few months of stability, my Windows 11 machine started doing the same thing. It is seriously frustrating. Microsoft please fix this issue it dates back to Windows 10.
Anyway, I remember a hack from a similar issue on Windows 10. Continually pinging the gateway
From a command prompt run the command
ping -t 192.168.0.1
Replace the 192.168.0.1 with your gateway. Use the command ipconfig /all to see what your gateway is
It's actually more stable than before. Actually what seems to happen now, is when the wifi is about to drop, the ping stops wifi on the computer from going to sleep (I don't understand why but it seems to work).
If it works, add this command as a task using "Task Scheduler", so it runs this command when you log onto your account. Use "Create Basic Task", the command is ping, and the parameters will be -t 192.168.0.1