How does the reverse thrust work while landing?
During the landing reverse thrust of an aircraft engine is seen that the compressor fan rotates in opposite direction


This is wrong

Reverse thrust does not reverse the rotation of the fan/compressor/turbine.

Reverse thrust "simply" redirect the airflow coming out of the turbine in the reverse direction (well, almost, as we'll see in a moment) w.r.t. the usual one.

In the image you posted, the thrust reversers are deployed, and you can see them circled here: 



The airflow is the coming out not from the back of the engine, but from the sides, slightly directed forward. The thrust (i.e. the force that the airflow is imposing on the aircraft) is directed backwards, while normally is directed forwards, it is then reversed.

This is nicely illustrated in this image (source)



NOTE: there are different typologies of thrust reversers, this is only one of them, but none of them require spinning the engine in the opposite direction.