networking – How does the router not have conflicts with other devices as it is using the same public IP address? (NAT)

So I’ve been learning about NAT and how it allows us to reuse IPv4 addresses by using a NAT table and having basically an alias for the private IP to a public IP and vice versa along with storing the port. But something I can’t wrap my head around is that if there are packets being sent simultaneously which will use the same public IP address, how does the router know which device to send data to? Does it utilize MAC addresses? Does it utilize port numbers?

(If this doesn’t belong here, guide me to which StackExchange site I should post this on)