NAT and subnetting solve two different problems.
Problem 1: Previously IP addresses were divided into classes A, B and C. A class C address had a default subnet mask of 255.255.255.0 meaning 24 bits decide which network and the last 8 bits are for the host. With 8 bits for hosts you could have 2^8 - 1 = 254 IP addresses that are part of the same network.
Historically it was not recommended to have more than around 250 IPs on the same network because of broadcasts flooding the network which meant that class B networks, which have a default subnet mask of 255.255.0.0 with 16 bits for hosts, have way too many addresses for a single network. Even more so with a class A network.
Also most of the time we require many smaller networks with just a few hosts which is why we subnet. Subnetting is basically moving the boundary between the host and network part of the address. So by decreasing the number of addresses on each network, you can increase the number of networks.
Problem 2 is that, even with subnetting, we have way too few addresses for every device to get its own, which is why we've got NAT.
NAT or in this case PAT works by letting multiple private adresses share a single public IP address by mapping to a port number.
So, in the IPv4 address space, we have a few reserved blocks of addresses which are meant to be used locally on a private network, e.g. 192.168.0.0 with a subnet mask of 255.255.255.0. This network can be used on multiple sites at the same time because they are private and not allowed to be used on the Internet.
So when a device with a private IP wants to go out on the Internet, the private IP is mapped to a public IP address, together with a port number which means that multiple devices on a local network can share on a single public IP. This extends the number of devices that can access the Internet.
If the server is on the same network as your PC it will communicate with your private IP. If the server is on the Internet, it will communicate with your public IP on a specific port which your router maps to your private IP.