I recently had a problem connecting wirelessly to a router. I found the network with my router's SSID, clicked Connect and entered the encryption key. I got error messages repeatedly about the key not matching. The solution in my case was to set up the wireless connection manually when it did connect successfully. That may be worth a try.
Samsung Galaxy S8 review