Hold the button until it goes in to setup mode. This method of putting the device into setup mode will now (since 3.17) also clear the non-volatile memory area where wifi settings are stored and should resolve any data corruption there.
The frameworks and OS store WiFi settings, as well as a few other things in a special section of flash memory in a key-value database. I suspect these issues are caused by data corruption in that database, and I suspect that is what causes both wifi amnesia and random SSIDs.