I'd like to start this answer by reminding readers that Mercutio is just about as hot tempered as Tybalt. Tybalt always gets the blame for having a quick temper, but Mercutio is just as bad. Benvolio even states the fact in Act 3, Scene 1.
"An I were so apt to quarrel as thou art, any man
should buy the fee-simple of my life for an hour and a quarter."
That is the same scene where Mercutio and Tybalt fight each other too.
I believe that Mercutio chooses to fight Tybalt for a few reasons. First, the day is hot. Benvolio states the fact at the very beginning of the scene, and he says that the hot weather always puts people in hot tempered moods. Mercutio likes fighting in the first place, and the weather is making him crankier.
Second, Mercutio is still upset that Tybalt sent a formal challenge to Romeo. Mercutio knows that Tybalt is dangerous, and as Romeo's friend, Mercutio feels the need to protect his friend.
Third, when Romeo finally shows up, Romeo essentially just stands there and takes insult after insult from Tybalt. Mercutio is angered by the insults and angered that Romeo isn't willing to do anything about it. Mercutio eventually gets to the point where he can't idly stand by and watch anymore. He feels compelled to jump into the fray and fight Tybalt. Unfortunately Mercutio's actions get himself killed.