In some versions of Android Studio, connecting to devices over Wifi doesn't work. They connect once, but never again until you restart the IDE. Fortunately, this can be done using commands. This script just makes connecting a slight bit easier
Source For Commands
All you have to do is download the .bat or .ps1 file, and then follow the instructions on the screen. This script only work on Windows, and you need to have Wireless debugging enabled on your Android 11+ phone.
Note: If it doesn't connect first time around, run the script again. Sometimes it rarely only works on the second time