It's not surprising, if a bit unsettling to some, that many of the freedom fighters got attracted to the lure of socialist ideas for nation building while dreaming for an independent India. Socialism was like the Spirit of the Age in pre-independence India. It was Karl Marx, the father of communism, who inspired many Indians through his writings during the Russian Revolution.
Bal Gangadher Tilak was among the first Indian freedom fighters to praise Marx's philosophy and the Russian communist revolutionary Lenin. Subhash Chandra Bose, the fascist leader of the Indian National Army, had inclinations towards authoritarian means for creating a socialist nation. He thought of Soviet Union as a role-model-nation for India and believed (post WW II) that democracy would not work in a country like India. He had major disagreements with Gandhi's non-violent methods for attaining independence, and was an advocate for a violent resistance. [He was elected as the president of Indian National Congress for two consecutive terms, but resigned because of his ideological differences with the Mahatma.]
Another revolutionary, Bhagat Singh, was also attracted to the Marxist principles of revolutionary Communism. After becoming the leader of Hindustan Republican Association, he changed its name to Hindustan Socialist Republican Association in 1928. Like Netaji, he also believed that a vast and diverse country like India could survive only under a socialist government. He wrote in his letter to the Governor of Punjab “Till Communist Party comes to power and people live without unequal status, our struggle will continue. It cannot be brought to an end by killing us: it will continue openly as well as secretly.”
In the famous statement on June 6, 1929, Bhagat Singh said, “The whole edifice of this civilization, if not saved in time, shall crumble. A radical change, therefore, is necessary and it is the duty of those who realise it to reorganise society on the socialistic basis. Unless this thing is done and the exploitation of man by man and of nations by nations is brought to an end, sufferings and carnage with which humanity is threatened today cannot be prevented.” [source]
On the other end of the political spectrum of pre-independence India, the Indian National Congress also believed in the socialist idea and set it as a goal for free India. Nehru, the first prime minister of independent India adopted socialist practices for industrial and economic development as well as for social reforms in India. While many argue today that the liberalization should have taken place as early as the 70's (as opposed to the 90's), it remains a topic of debate whether implementing free market economy right after freedom could have been a wise alternative to 'centralized planning'.
The National Planning Committee (NPC), which was set up in 1938, was in charge of deciding economic policy for India that was soon to be free. The NPC took lessons from Russia and Japan where state intervention was needed and helped tremendously to annul the effects of late industrialization. This 'late industrialization' effect was even more prevalent in India which had been under colonial rule for over 200 years. So the NPC suggested "service before profit" policy, and notably the private sector agreed with this strategy. In 1944, a group of leading industrialists published A Plan for Economic Development for India (which was later known as the Bombay Plan), in which they expressed the need for state intervention especially in energy, transportation and infrastructure. These capitalists concurred that, positive and preventive functions of the state are essential to any large scale economic planning in the early stage of industrialization.
During the Emergency of 1976, the word socialist was added to the preamble of the Constitution of India:
WE, THE PEOPLE OF INDIA,
having solemnly resolved to constitute India into
a SOVEREIGN SOCIALIST SECULAR DEMOCRATIC REPUBLIC and to secure to all its citizens:
JUSTICE, social, economic and political;
LIBERTY of thought, expression, belief, faith and worship;
EQUALITY of status and of opportunity;
and to promote among them all
FRATERNITY assuring the dignity of the individual and the unity and integrity of the Nation; [link]
(Emphasis is mine.)
Even after India has shredded off its socialist ideals in 1991, when the prime minister Narsimha Rao and the finance minister Manmohan Singh, introduced economic liberalization which spurted a tremendous economic growth in last couple of decades, India continues to be described a socialist republic in the preamble to the constitution! [Several months ago, the SC surprisingly refused to entertain a petition which urged to remove the word socialist from the preamble.]