Hi ,
I had the same issue with my MacBook Pro M2, wifi disconnecting and would not reconnect even when placed next to the wifi router so exclamation mark on wifi signal at top of screen would display and only way to fix would be to cycle power. This would happen once a week but went to once a day. I did all the router resetting and cycling power but it would reoccur. Wifi diagnostics would be fine. When failing it had also cleared the ip address of the MAC or self assign with a number not on the network, router address was lost , or both at the same time.
I fixed this by backing up the device via time-machine, and resetting the MacBook Pro under the system settings General/Settings/Reset.
I used it for a week like this and the problem had gone away, so I Reset the MacBook Pro again, and on restart you have the option of transferring from Time Machine backup. Once this is accepted and you inform it where the Time Machine back up is it gives you three options -data-applications-settings. I picked all but the settings and transferred data from back up. Computer is now wifi glitch free and has been for the last 3 weeks.
Originally when I set this MacBook Pro up from new , I transferred from a Time Machine back up of my previous MacBook Pro. The WIFI fault was there from new, something like once a month it would occur. Not sure if an error occurred during original time-machine transfer, or maybe some incompatibility to introduce this fault.
Anyway wifi issue free now.
Dave J