How does a phone decide which Wi-Fi network to join?
Through a stored priority list and a continuous signal assessment, which together explain the two behaviours people find most annoying: clinging to a weak network, and joining the wrong one.
How networks are remembered. When you connect, the network name and credentials are saved. The device then scans periodically and, when it recognises a saved network, joins according to its own ranking — most operating systems prefer the most recently used, then signal strength, then security type.
Why phones cling to a weak signal. This is the notorious sticky client problem. The decision to leave an access point belongs to the device, not the network, and most devices are conservative: they hold on until the signal is genuinely poor, long past the point where a nearer access point would be better. Walking from one end of a house to the other, your phone may stay on the distant router while standing next to a much closer one.
What helps: roaming standards that let the network suggest a better access point and supply neighbour information so the device does not have to scan blindly, plus letting the network gently disassociate a client that should move. Mesh systems implement these, which is most of why they feel better than an extender.
Why a phone joins the wrong network: identical names on different bands; a saved public network seen in passing; and open networks with names deliberately matching common hotspots — the basis of the evil twin attack, since a device configured to auto-join a network name will join any network broadcasting it.
Why 2.4GHz sometimes wins when 5GHz would be better. If both bands share one name, the device chooses, and 2.4GHz travels further so appears stronger while being slower and more congested. Band steering tries to manage this, imperfectly.
What you can control: forget networks you no longer use, which also reduces attack surface; disable auto-join for public networks; turn off auto-connect to open networks entirely; and where a device consistently picks badly, separate the band names so you can choose deliberately.