When a packet moves from a private (inside) network to a public (outside) network, the NAT device (router/firewall) rewrites the source IP address (and maybe port) of the packet to a public (global) address. When the return packet arrives, the NAT device uses a translation table to map the destination (which is the NAT device’s public address) back to the original internal (private) host and forwards accordingly.
For example: A host 192.168.1.10 sends a packet destined for a public server. The NAT device rewrites the source to, say, 203.0.113.5 (its public interface), and tracks that mapping. When the server replies to 203.0.113.5, the NAT device looks up the mapping and sends it to 192.168.1.10.