This is ensured by the Air Traffic Controllers (ATCs). The ATCs monitor the flying aeroplanes from the ground, their position, speed, and their altitude (height). It is very important to check these, so that the airplanes could be kept safe. Air Traffic Controllers can see it on their screens as blinking dots. The airplanes look like blinking dots on the radar. So the next question is, how do the ATCs get this information?
The details of every single plane. They get this information from the RADAR. Radar is a device that uses radio waves to detect objects that are at a distance from it. Radar can detect airplanes, spacecraft, and even tornadoes. But the radar used to detect airplanes, can be classified into 2 parts.
Primary radars and secondary radars. Primary radar is a system for which antennas have been placed at strategic locations all over the world, those antennas emit radio waves, and when the radio waves return after being reflected by the airplanes, they calculate the distance of the plane based on the time taken by the radio wave. Primary radars can tell you the horizontal distance of an airplane, but they can tell you the altitude of the airplane.
Secondary radars are used to calculate the vertical distance. This is a complex bit of technology. A transponder is placed on top of an airplane, And the radio wave signals from the primary antennas, are caught by the transponder, and responds with its own signal. With this, it provides more information about the position of a flight much more reliable information.