The southwestern summer monsoons occur from June to September.
The Thar Desert and adjoining areas of the northern and central Indian subcontinent heats up considerably during the hot summers.
This causes a low pressure area over the northern and central Indian subcontinent. To fill this void, the moisture-laden winds( high pressure winds) from the Indian Ocean rush in to the subcontinent.
These winds, rich in moisture, are drawn towards the Himalayas.
The Himalayas act like a high wall, blocking the winds from passing into Central Asia, and forcing them to rise.
As the clouds rise their temperature drops and precipitation occurs.
Or Due to the presence of the himalayas , areas of low pressure develop in north and northwest parts of India. Because of this winds from sea( high pressure area ) begin to blow towards the land masses( low presure areas. So, a shift in the development of monsoon trough or low pressure trough along with the change of season is the main reason for the change of the flow of wind blowing from Allahabad towards the north.