Your concern is very valid.
Aircraft use two fundamentally different speeds: airspeed and ground speed. (Each of them has its own sub-species, but it doesn't matter for now). There is virtually nothing common between them, and depending on wind, you actually can have zero and even negative ground speed, or can fly 'supersonic' on a regular airliner, or climb while trying to descent. The devices to measure these speeds are also fundamentally different.
For airspeed, the aircraft use, basically, a barometer, which chamber is attached to a pipe pointed forward (Pitot tube).
And for some time, that was it. The airspeed measured this way is all you need to fly an airplane. After all, the airplane flies in the air and doesn't care about the ground (until it hits it :) The pilot would then navigate visually, by matching the map with the landscape.
On aircraft without GPS and navigational equipment (say, 50 years ago), you could get an idea of the ground speed by
- Knowing the weather forecast and thus wind at every point of your intended route;
- Calculating airspeed at the ground from the indicated measurements. For that, you need to take into account altitude and/or temperature. Pilots have special tools and instruments for that.
Yes, this is not an easy walk in the park, but that's part of the pilot's trade. Early airliners often included a dedicated navigator position to do such calculations along the route. And generally, it is still considered a useful skill and you need to do similar calculations when planning the route.
The next step is to use ground navigational aids and/or an onboard system that measures ground speed from the Doppler shift of the radio signal reflected from the ground. On some aircraft, the radar can do this job.
And finally, we have GPS that... no, it doesn't really measure ground speed. But it calculates it from precisely known speeds and position (with respect to grouond) of multiple satellites.