There are 6 batsmen in most sides, but only 4 bowlers, all of whom need their workload managed and have specific roles within the side, if you are playing in conditions that warrant only one spinner and he is having an off day and is therefore unable to pull his weight then the captain has bowl his seamers in long spells and the whole attack suffers quite a bit.
The team combination is definitely a factor, but when you have 3 pacers, plus an all rounder in Matthews, its pretty easy to fit in someone like Mendis.
And talking about bowlers in general,
Most teams look to play batting allrounders or bowling allrounders if not a proper all rounder. So a lot of times teams do have 5 bowling options, its not difficult to fit some one who can change the game on its head or not contribute at all. And for a bowler, its not like if he doesn't do well he has no second chances, even if he bowls one poor spell, there's time to make a comeback. In that case its worth taking risks.
People usually try to take an easy way out when it comes to the bowling line-up, there's hardly any creativity shown. Australians never took a chance with Krejza, whose bowling was typically suited to SC pitches, he might have been a hit or miss kind of a bowler, but his attacking off spin could have been useful in these conditions. India has desperately needed a 5 bowler strategy from a long time, but it never happens, finally we took a chance with Binny who is more of a batting all rounder. Before Praveen Kumar showed that a skilled swing bowler can be useful in tests, our selectors usually didn't take chances with medium pace swing bowlers, usually the guys who could bowl somewhere around 135ks or more have got preferences.
I think this is usual, selectors and captains are very negative and defensive when it comes to taking risk with bowlers.