About P2P networking In P2P(peer-to-peer) networking, it is possible for the server program(software) and the client program(software) to be running on the same computer.

So the two must have the same IP address.

I am confused about this. Is there nothing going wrong if both of them uses the same IP address?

Please clarify.
Sure.  That's fine.  Nothing wrong with that.  Transport-layer protocols (such as UDP or TCP) use port numbers so that you can run multiple applications on the same machine without any difficulty.