How to use while loop in arduino for infinte loop
The find method reads the characters until the searched string is found or a timeout interval is passed.

In your case if the connection is not successful, the first find will not find "WIFI" and will read all the input including the "+CWJAP:3", then on timeout it returns false. The second find will wait until timeout and then return false.