Nobody types in IP addresses for every phone that joins the Wi-Fi. DHCP (Dynamic Host Configuration Protocol) does it. A new device broadcasts a Discover; a DHCP server (usually the router) replies with an Offer; the device sends a Request for that offer; the server confirms with an Acknowledge. People remember it as DORA.
The server hands out four things: an IP address, the subnet mask, the default gateway and the DNS servers to use. The address is a lease, lent for a set time (often a day). The device renews it before it runs out, and usually keeps the same address.
The default gateway is the router's address on your subnet. A device sends a packet straight to the destination if it's on the same subnet (it checks with the mask), and to the gateway for everything else. A wrong gateway is a classic fault: you can reach the printer but not the internet.
To send any frame on the LAN, a device needs the destination's MAC address, not just its IP address. ARP (Address Resolution Protocol) finds it: the device broadcasts "who has 192.168.1.1? tell 192.168.1.20", and the owner replies with its MAC address. The answer is kept in an ARP cache for a while, so it isn't asked every time.
For a packet to another network, ARP asks for the gateway's MAC, not the far server's. The frame goes to the router, while the IP packet inside still carries the server's IP address. At each hop the frame is rebuilt with new MAC addresses; the IP addresses stay the same the whole way.