How come aircraft are not colliding with each other in the air?

Safe aircraft traffic is the ultimate goal!
On normal days, tens of thousands of planes can be seen in the skies of the world, with millions of people flying safely from place to place.
This heavy traffic of all the planes at high speed is conducted safely and without accidents because of a number of measures.
As in any field in civil aviation, safety is achieved by several layers of protection, and the result – safety in the sky!

1. Avoiding congestion for safe aircraft traffic

you may have heard the pilot says that we are being held due to a ‘slot’.
This is because every airline flight has to submit a flight plan, and the control centers only allow a certain amount of aircraft at any given moment in every volume of air.

2. Air Traffic Control

While in the air, the pilot communicates with the Air Traffic Controller (ATC) of every area and gets permission to fly according to the flight plan.
In some cases, the pilot gets modifications to the plan in order to keep the required distance between flights at the same altitude.
The ATC has its own computerized system that can predict unsafe distances and this system alerts the ATC, which in turn instructs the pilots to change course or altitude.

3. Altitude Separation

Aircraft fly in even or odd altitudes 32000, 34000 Vs. 33000 or 35000 feet depending if they fly in a westerly or easterly direction. this is how the separation of 1000 feet is kept between aircraft that fly opposite to each other.

4. TCAS

the last barrier that avoids accidents is the TCAS. this system is VERY reliable and installed in all the aircraft that fly in the sky. This system alerts the pilots and gives them accurate and reliable instructions so they can avoid a collision. The instructions of this system have the highest priority BY LAW and the pilots must obey these commands.
An example of how accurate is the TCAS was given in an Independent article on Oct. 2nd, 2018 where 2  Ryanair planes were involved in a near-miss over northern Spain.
Here is the graphic description of the event:
Please note the closest distance between these 2 aircraft was 3.9 Nautical miles and 300 feet. These two planes were close but not about to collide.
But in aviation – this was considered a serious event and required formal investigation.
Safe aircraft traffic is a reality
I have been flying for more than 40 years now. I have never experienced a situation in which the TCAS system gave me collision-avoidance instructions. This is how safe is the entire aviation world.
The clip shows a SIMULATED action of TCAS.