When i create subnets in my VPC, should each subnet have a unique IP range ? if the IP ranges are same, example, 10.128.0.0/20, then a VM created in each subnet may have 10.128.0.1 IP. each subnet may have a VM with this same IP. when i ping by IP which VM is hit ?
Yes, each subnet would need to be unique within a VPC. Otherwise you get an error when trying to create a new subnet with an existing CIDR block.
To add on to T.J.’s answer above. If you could add the same subnet again routing would not work correctly. I’ll do a quick example to help explain it.
Subnet A : 10.1.1.0/24. with a host 1 on 10.1.1.30
Subnet B : 10.1.1.0/24 with a host 2 on 10.1.1.60
So when host 1 wants to talk to google.com it ask dns where it is and gets an IP (today for me 18.104.22.168)
host 1 looks at the subnet mask and sees if 22.214.171.124 fits in its own sub net since 10.x.x.x and 216.x.x.x are not covered in the same subnet (10.1.1.0/24 has IPs 10.1.1.1 to 10.1.1.255 in it) it puts packets to 126.96.36.199 to the router for it to find the way to 188.8.131.52.
Now if we have somehow peered Subnet A and Subnet B…. Host 1 wants to talk to 10.1.1.60 it looks to see if 10.1.1.60 is between 10.1.1.1-10.1.1.255 (as defined by the Subnet mask) and sees that it is so it sends a packet to the local network and not to the routers. As they can only talk via routers this fails.
The short story is it is blocked because routing between them will not work correctly. In large enterprise environments where you have private (1918 space) networks on premise may want to have VPN or highbandwith links to the on prem environs you can still have issues with this.