The image shows a geared turbofan with two concentric shafts.
The outer shaft is connected to the final compressor stages and the first turbine stages.
The inner shaft connects the first compressor stages and the final turbine stages.
Hot air from the combustor drives the first turbine stages (and thus the outer shaft) in a clockwise direction (when viewed from behind in the direction of flight). The vanes of the final turbine stages are the other way around; they rotate the inner shaft (an thus the first compressor stages) in a counter-clockwise direction.
The fan up front is connected through a gearbox to the inner shaft. The gearbox reduces the rotation speed and reverses the direction. Thus the fan rotates clockwise again.
The reason to have multiple shafts and a gear box is that each stage functions optimally at different rotation rates. You want to avoid supersonic speeds as much as possible, since the shockwaves of supersonic blade movement decrease the efficiency. Only the blade tips are allowed to go supersonic.
Therefore, the fan, which has the largest diameter should spin slowest.
The first compressor stages and the final turbine stages have lower diameter, and thus can go much faster.
The final compressor stages and the first turbine stages have even smaller diameter and see very hot air (and thus higher speed of sound) can rotate even faster.
By having two shafts and a gearbox, the design is optimised for every stage. (some designs use three shafts).
Reversing the direction of rotation helps keeping the general airflow aligned with the axis of the engine, which is more efficient than creating a swirling airflow.