Your ping dates back to 1981
When you measure your game connection, you are using an echo message standardised in September 1981, in RFC 792 by Jon Postel. The test procedure is more than forty years old and still works exactly the same way.
The standard explicitly requires that the data received must be returned in the reply. That is why ping truly measures the full round trip, not just whether the other side is alive.
UDP: deliberately without guarantees
The UDP protocol from 1980 has a header of just eight bytes, and its standard states verbatim that delivery and duplicate protection are not guaranteed. That sounds like a flaw but is a decision: resending a player position from a hundred milliseconds ago would be pointless, so lost data is dropped and the next, current state is sent instead.
TCP: everything arrives, but you wait
TCP does the opposite. According to the current standard, RFC 9293, its reliability consists of detecting losses via sequence numbers and errors via checksums, and correcting both through retransmission. Everything arrives, and in the right order; when something is missing, everyone waits.
And before a single byte of payload flows over TCP, three messages are needed: request, acknowledgement with counter-request, acknowledgement. The standard calls this the three-way handshake. Every connection setup therefore costs you at least one full round trip to the server and back before anything is transferred.
What this means for your game
Games mostly use the UDP path for position data, because late information is worthless there, and the TCP path for login or shop, because nothing may be lost there. Your ping is the one number underneath both worlds: the pure round-trip time. It also explains why switching to a server in a distant region instantly feels more sluggish, without anything changing on your PC.