India had a policy of non-alignment during the cold war. But just before war broke out between India and Pakistan in December 1971, India signed the treaty in August 1971.
What were the reasons that made India to do this?
The Indo-Soviet Treaty of Friendship and Cooperation was signed in the aftermath of General Yahya Khan's imposition of martial law in Pakistan and Pakistan's military intervention and genocide in East-Pakistan.
The Indian government clearly wanted to intervene in East Pakistan, if for no other reason than the growing humanitarian and economic crisis on its border. While they may have been confident of victory against Pakistani forces, the question of how China and the United States may have reacted would clearly have been a concern. This would have been particularly true in light of the defeat that India had suffered against China in 1962.
The Indian government found the Soviet leadership open to negotiations on a treaty, and those negotiation culminated in the signing of the treaty on 9 August 1971. This sent a clear signal to Washington and Beijing (and may even have helped to hasten Nixon's visit to China in 1972).
The Indo-Pakistani War of 1971 was fought in December of that year.
Before the Indo-Pak war of 1965, UK was the official supplier of defense products to India. After the war, UK started to limit the supply. So, India wanted the second ally. Aas USA was already occupied by Pakistan, and Pakistan also signed a friendship treaty with China, India wanted a strong ally.
Now, the question remains, why India signed the treaty in 1972, why not in 1966?
The answer may lie in the traditional procrastination of India.
India has regional parliaments and a federal parliament with multiple assemblies. This system is theoretically fantastic, but practically a nightmare for development. Indian politicians waste a lot of time in their parliaments to take simple decisions. For example, It took 16-years for Indian parliament to pass tax reform bill, it took 15 years to sign LEMOA with USA.
Then come bureaucracy and red tape. India is a bureaucratic nightmare for businesses. A Hong Kong-based company found that India was the worst place to do business in Asia. Simple decisions take years to finalize. Some examples that bureaucracy ate up India are, Indian MBT project took 35 years to finish, and Indian jet fighter project took 33 years to finish.