I've heard different stories on why Sardar Patel was not selected for PM post. Some says it was Gandhi who opted Nehru over Patel, whereas some suggests it was Sardar Patel who stepped back from PM post.
Patel himself withdrew from the race on Gandhi's request. As for why this request was made by Gandhi, this is a matter of speculation since Gandhi would rarely give reasons for his decisions. People speculate that it could be due to either Patel's close relations with the Hindu right-wing, and his acrimony with the leftist leaders. Though Nehru had never gone against Gandhi's wishes publicly, he was never known as a Gandhian leader.
There were some practical and some psychological reasons for Gandhi's soft spot for Nehru.
Nehru had wanted to give his Trust fund to Mahatma and adopt a simple life. This was a purely emotional decision. Gandhi, who had lost his beloved father at a young age, was greatly touched by the mutual love between father and son. When Motilal died he said 'his love for India was part of his love for his son'. The Nehru family, though never adopting Gandhian ideology, nevertheless felt that they needed to be purged of their materialistic life-style so as to, in some mystical manner, be merged with the silent and suffering masses. After Nehru lost his ancestral wealth, instead of taking money from Dalmia or one of the other wealthy industrialists, he made himself independent by writing books. This greatly raised his prestige with people like Birla and Bajaj. Gandhi could see the Nehrus were bringing money into the movement, not acting as a drain upon it. Furthermore, the Nehru family showed unity- even when Motilal and Jawaharlal disagreed they maintained the decencies. By contrast Patel and his elder brother often disagreed- the latter prefered Bose in Bengal to Gandhi's faction.
Nehru had good relations with Atlee and later with Mountbatten but did not take an independent line on this basis- this strengthened Gandhi's hand. It made sense for Nehru to be a figure-head P.M (more especially as he was a Hindi/Urdu speaker from the 'heartland' and his family had the support of the smartest Muslim politician of U.P- Rafi Ahmed Kidwai) while Patel carried the big stick. However Patel failed to control Liaqat because the clever young aristocrat had got the Muslim Civil Servant on side and used his position as Finance Member to paralyse the administration- this made Partition inevitable.
Nehru preferred to deal with strong regional leaders, Patel was more autocratic- the circumstances were such that Nehru's 'big picture' romanticism was what powerful regional satraps would tolerate. Indeed, in 1946, most people thought India would be a loose federation. The Chief Minister of Bombay or Madras would have more power than the P.M at Delhi. Partition and Linguistic re-organization militated against this.
Nehru's leftward tilt was, of course, quite important to Gandhi who, in 1942, very dramatically changed his mind about Bose and the I.N I s Unlike Patel, Nehru wasn't a great organizer but he was quite easily managed by his Civil Servants. His profound defeatism re. India's poor's chance of progress made him a grumpy but safe guardian of Gandhi's legacy of stupidity, starvation and weird hang-ups about sex.
Sardar Patel got off to a "bad start" with Gandhi.
"Upon hearing of Mohandas Gandhi, he joked to Mavlankar that Gandhi would "ask you if you know how to sift pebbles from wheat. And that is supposed to bring independence."
It's true, per one of the comments that they took a liking to each other later, and that Patel became one of Gandi's closest adherents.
But Patel may have clashed with Gandhi again later.
"Criticism arose from Bose's supporters, socialists and other Congressmen that Patel himself was acting in an authoritarian manner in his defence of Gandhi's authority."
These (and other factors) may have caused Patel to lose a "horse race" with Nehru for Gandhi's endorsement. Even a small amount of "friction" may cause a leader to (dis)favor one supporter relative to another.
Motilal pushed for son Jawahar as Congress chief in letter to Bapu
Motilal Nehru, wrote a rare letter to Mahatma Gandhi saying although Sardar Vallabhbhai Patel was the best choice for the post of Congress president, the party should now be handed over to young leaders of "Jawahar's type".
The neo-feudalistic Nehru, hated Patel who was from agrarian background, and the Feudal Arrogance of Nehru could not imagine himself to be none other than the Supreme, he would have played dirty games even if Mahatma were to on the top seat. He coerced Mahatma who too was unfair and wrong at least in this episode of the history, for asking Patel to withdraw the candidature.It was the first stab on democracy.