The problem usually exists (if your pc is older than 2yrs) most likely because your battery's life is coming to an end and the battery is unable to completely power your WIFI adapter which is causing the issue you're currently facing. You can try out the below-mentioned fixes.
Fix 1: WIndows+X, go to device manager, then to network adapters expand it and then right click on the wireless adapter option then update the driver.
Fix 2: If it is already updated go to network and internet settings and click on network reset, then reboot your pc.(Also you can uninstall your wifi adapter and reboot your pc but there is a chance where it might not work and you will lose your wifi adapter and then you have to reinstall it or choose pc recovery option)
Fix 3: If that doesnt solve go for LAN if you have the option.
Fix 4: If you cant use LAN buy an external Wifi Adapter it usually costs less than 10€.