I've heard some pitches will support only fast bowlers and some pitches only spin bowlers. What is the mechanism behind this? How can a pitch support either one? What will be difference between these two pitches?
Pitches with a lot of grass on them aid fast bowlers, since the ball comes on quicker to the batsman.
Dry and dusty pitches favour slower bowlers, since it allows the ball to grip and turn in the cracks on the pitch. These factors are very important when picking your side, especially in the longer formats of the game.
This is why most sides tend to bat first in tests, since the wear and tear that the pitch endures for 5 days opens up the cracks, and brings the spinners into play. A very recent example of this would be the recently concluded 2nd test of NZ vs ENG, where Graeme Swann took a ten-wicket haul, 6 of them in the 2nd innings.
Example of cracks in the pitch -