It's hard to give only one reason why they weren't conquered. They may have served as buffer states for a period, but this argument can't be the true motive and can't be extended for the entire period of Turkish domination. While Moldavia was situated between the Ottoman Empire and Poland, the Turks did have a common border with the Poles further east. Also, Wallachia is nowhere near Poland. It was indeed situated between Turkey and Hungary, yet so were Serbia and Bosnia, which were eventually occupied.
One reason may be the Danube, which forms a nice defensible border. Another may be that it was quite profitable for the Ottoman Empire just to receive an anual tribute, without having to pay for an occupation force to pacify the locals. In fact, it's possible that this was the only profitable option. IIRC, the revenues obtained by the Turks from occupied Hungary were less than the money needed for garrisoning the province, so that territory was actually a drain on the budget.
A third reason may be the boyar class. They were quite happy to live in state vassal to the Turks, having as ruler a weak prince (this state of affairs maximized their autonomy), but were strongly against an annexation to the Ottoman Empire. So they were ready to support a strong prince if the Ottoman danger increased, but were equally ready to betray that prince and install an weaker one after the danger subsided. I think their preferences, from worst to best, were as follows: state occupied directly by the Ottoman Empire; independent country with a strong prince; vassal country with a weak prince. An example for this trend is the 1462 Ottoman campaign in Wallachia. In the initial stages, Vlad Tepes managed to force the Turks to retreat south of The Danube, but after that, the boyars betrayed him and he was replaced as prince by his brother.
Geography may have played a part, too, in preserving the autonomy of the two romanian principalities. They are covered mostly by plains, but they do have mountains in the region opposite to the Turkish border, mountains which form a convenient place to retreat to before launching a counterattack. Also, Transylvania is just beyond those mountains, better protected and able to supply help.
That's all I can think of for the momment.
And a minor correction:
Karl Martell said:
And there's also the story about how Vlad Dracul of Wallachia grossed out the Turkish when they came to conquer his land...
I think you're talking about Vlad Tepes, known in the West as Dracula. Vlad Dracul was his father. All of Vlad Dracul's descendents took the surname Drăculea, including his son, incidentally also named Vlad. The Hungarian nobles in Transylvania couldn't pronounce his surname, so they changed it into Draculia (or Draculya?). Later, the "i" or "y" was dropped and so we have the name Dracula.