He was apparently considered too controversial for the standards of the committee. To summarize the page that @yannis indicated:
In 1937 Ghandi's nomination received a not very enthusiastic review report from Jacob Worm-Müller saying that
"He is a freedom fighter and a dictator, an idealist and a nationalist. He is frequently a Christ, but then, suddenly, an ordinary politician. [...] One might say that it is significant that his well-known struggle in South Africa was on behalf of the Indians only, and not of the blacks whose living conditions were even worse.” [...]
We do not know whether the Norwegian Nobel Committee seriously considered awarding the Peace Prize to Gandhi that year, but it seems rather unlikely.
For the 1947 nomination Jens Arup Seip
wrote a move favorable report
“from 1937 up to 1947, led to the event which for Gandhi and his movement was at the same time the greatest victory and the worst defeat – India’s independence and India’s partition” [...] In all these matters, Gandhi had consistently followed his own principles of non-violence.
However the committee was ultimately split 2 (in favor) vs 3 (against):
From the diary of committee chairman Gunnar Jahn, we now know that when the members were to make their decision on October 30, 1947, two acting committee members, the Christian conservative Herman Smitt Ingebretsen and the Christian liberal Christian Oftedal spoke in favour of Gandhi. One year earlier, they had strongly favoured John Mott, the YMCA leader. It seems that they generally preferred candidates who could serve as moral and religious symbols in a world threatened by social and ideological conflicts. However, in 1947 they were not able to convince the three other members. The Labour politician Martin Tranmæl was very reluctant to award the Prize to Gandhi in the midst of the Indian-Pakistani conflict, and former Foreign Minister Birger Braadland agreed with Tranmæl. Gandhi was, they thought, too strongly committed to one of the belligerents.
Jahn himself was against on grounds that sound similar to those Worm-Müller from a decade before:
“While it is true that he (Gandhi) is the greatest personality among the nominees – plenty of good things could be said about him – we should remember that he is not only an apostle for peace; he is first and foremost a patriot.“
As for the 1948 posthumous nomination, the committee was also against (despite another positive report from Seip), but mostly on procedural grounds:
Nobody had ever been awarded the Nobel Peace Prize posthumously. But according to the statutes of the Nobel Foundation in force at that time, the Nobel Prizes could, under certain circumstances, be awarded posthumously. [...] The Director of the Norwegian Nobel Institute, August Schou, asked [...] the Swedish prize-awarding institutions for their opinion. The answers were negative; posthumous awards, they thought, should not take place unless the laureate died after the Committee’s decision had been made.
On November 18, 1948, the Norwegian Nobel Committee decided to make no award that year on the grounds that “there was no suitable living candidate”. Chairman Gunnar Jahn wrote in his diary: “To me it seems beyond doubt that a posthumous award would be contrary to the intentions of the testator.” According to the chairman, three of his colleagues agreed in the end, only Mr. Oftedal was in favour of a posthumous award to Gandhi.