Gerrit Cole (3-0) remained unbeaten in his brief major league career, turning in 6 1/3 innings while allowing two runs on four hits.
Cole's other two starts resulted in victories over San Francisco on June 11 and the Los Angeles Dodgers on June 16.
Alvarez hit a solo homer in the second, his 17th of the season, and Mercer delivered a two-run blast.
Both Los Angeles runs came in the seventh, one of them on a homer by Albert Pujols.
Jason Grilli worked the ninth for the Pirates, striking out two while collecting his 26th save.
Los Angeles outfielder Josh Hamilton missed the game and could miss the entire series with a sore right wrist. Hamilton is batting .207 after signing a contract that will pay him more than $17 million this season.
Jered Weaver (1-4) was charged with the loss, surrendering four runs on nine hits in six innings.
Celebrity Couples of 2014 [PHOTOS]