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.
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.