The multi home run game was the eighth for Pujols, who has 34 homers and 89 RBIs, which also leads the majors. He has 31 multi home run games in his career.
Chris Carpenter (8-3) blanked the Diamondbacks over eight innings, allowing seven hits and striking out seven.
Miguel Montero hit a homer off reliever Jason Motte for Arizona's only run.
Ryan Ludwick drove in two runs and extended his hitting streak to 10 games with a two-run single, and Nick Stavinoha hit a two-run pinch homer for the other St. Louis runs. Yadier Molina matched his career high with four hits, all singles.
Pujols, who struck out in his first at-at, led off the fourth against Arizona starter Jon Garland (5-9) by hitting a pitch 386 feet into the Cardinals' bullpen in right.
When Pujols came up to lead off the sixth, Garland appeared like he would pitch around him, with his first three pitches out of the strike zone. But Garland threw his next one over the plate and Pujols swatted it 435 feet off the facade of the upper deck in left field.
The Diamondbacks took no such chances an inning later, as reliever Scott Schoeneweis intentionally walked Pujols with two outs and runners on first and third to load the bases. That backfired when Ludwick dumped a single to right off reliever Esmerling Vasquez to make it 4-0.