In baseball, which I grew up with, it's always considered an advantage to bat second. In cricket I'd expect this to be even more true, because in addition to knowing what your target is when batting, you also have the possibility of forcing a draw if you find yourself losing. But I've noticed that captains who win the toss sometimes choose to bat first. Why is that?
I think, in Cricket, it is not always the case of win the toss & bat first or win the toss & bat second. The case, sometimes is also, win the toss and bowl first or win the toss and bowl second. Whether the decision is emphasized by bowling or batting completely depends on the pitch conditions and weather.
Let us take the case of Test cricket first.
In conditions like Australia, New Zealand, South Africa & England, where the pitch is more hard & grassy, that helps a fast bowler in swing & seam bowling. Since the game starts early, the grass is fresh & moist & aids swing & seam, hence in these particular countries, the decision is, mostly, win the toss & bowl first. That means, the batting, invariably, comes second. Also, the pitches in these regions dont crack much & dont deteriorate even on day 5, so batting last on day 5 is not that troublesome. Thus, most captains win the toss & choose to bowl first.
On the contrary, in places like India, Pakistan, Srilanka, Bangladesh, pitches are dry, dusty & less grassy, naturally conducive to spin bowling rather than fast bowling. Also, the pitch is a death trap on day 5. Only a handful of teams have managed to win a game chasing a decent score on day 5. Thus, in these countries, the emphasis is on batting. Mostly, captains who win the toss, chooses to bat first.
Coming to One Day Internationals,
The decision is heavily tilted in favor of batting rather than bowling. So the decision to bat first or second, on winning the toss, depends on the situation of the tournament & the kind of players in the team & less on the pitch & country.
However, it must be said that for stadiums, that are located in tropical climate with high humidity, in winter season, and in day-night matches, the decision after winning the toss depends on dew factor. If there is going to be dew in the night session, most teams choose to bat second after winning the toss, as it is very hard to bowl with a wet ball. The bowl doest swing, seam or spin as it becomes heavy with water. So, batting in the dew is easy.
But in non dew conditions, the decision is on the stage of the tournament & the kind of players. If you are in the finals, win the toss & bat first. Whatever score you put in, it takes nerves of steel from the opposition players to chase it down especially if they lose early wickets. Also, if you have the players who own the factory that manufactures nerves of steel like Micheal Bevan, Virat Kohli, MS Dhoni then yes, win the toss & bat second.
I am no expert but in a lot of cases it is because of conditions. If they feel the pitch will get worse they would prefer bat to in more consistent conditions. Or if the weather forecast is to change to or from inclement weather; eg heat or rain, they will want to bat/bowl under the conditions they can take advantage of.
In almost all conditions, the pitch will be better for batting first up. There will be few cracks for the ball to hit and it will be less likely to crumble and allow a lot of turn for spin bowlers.
Additionally, there is less scoreboard pressure. You can score at your own rate and not worry about time (In tests) or expectations based on the team who batted first.
Also fielding in Tests is hard work. Out in the sun all day while only 2 players of the batting side are out in the sun. Batting first might mean you stay fresh while the other team toils away.
Forcing a draw if you find yourself losing -> there is no option of forcing a draw in Limited overs cricket (ODI or T20). only a tie is possible if both the scores are equal. In limited overs day night game if there is dew possible at night the caption will decide to bowl first as the bowlers find it hard to grip the ball later.
Incase of First Class or Test Cricket. There are lot of factors behind the captain choosing to bat/bowl first. Most important factor would be the pitch. In sub continent conditions where the pitches tend to deteriorate as the match progress it will assist the spinners a lot. In that case you wouldnt want to be batting on day 4 or 5. The team will be looking to score more runs on day 1 or 2.
If the pitch is green and lot of grass or overcast the captain decides to bowl first to make use of the conditions because it will assist the seamers.
Apart from the pitch factor the team`s strengths and weakness also plays a part in decision making.