If there are two PCs with same IP address on a LAN, what would happen if I ping that IP address from another PC on the same network and why?
Actually, the ping gets sent to a layer-2 address if they are on the same LAN. Assuming ethernet, the sending host may have a MAC address in its ARP cache, and the pings gets sent to the host with that MAC address (end of story).
If the host needs to send an ARP request to resolve the layer-3 IP address to a layer-2 MAC address, this is where it gets tricky. The ARP request is a broadcast so that all the hosts on the LAN get it, and both hosts with that IP address will respond with a MAC address for that IP address. The first ping packet will probably go to the first MAC address received, and if all hosts are on the same switch, or the hosts with the duplicate addresses are on different switches than the sending host, you can't predict which one will be received first. The sending host will place the first received MAC address in its ARP cache for future use (subsequent pings, normally more than one ping is sent from a single user ping).
In the meantime, the sending host will receive the MAC address from the other host, and it is supposed to update its ARP cache and use that MAC address for traffic sent to that IP address. The next pings from the ping command should go to the second host with that IP address.
You just really have no way to know in which order the hosts will respond to the ARP request, assuming the sending host didn't have a MAC address for the IP address already in its ARP cache.