In the Rockies' first, DJ LeMahieu and Carlos Gonzalez delivered one-out hits and scored on Nolan Arenado's double and Gerardo Parra's fielder's choice grounder for a 2-0 lead against starter Rubby De La Rosa.
After Castillo's homer, Matzek walked Chris Hermann and Yasmany Tomas before Brandon Drury and Evan Marzilli delivered RBI singles for a 3-2 D-backs lead.
The D-backs' Kyle Jensen, who belted 47 homers in the last two Triple-A seasons with the Marlins and Dodgers organizations, added a two-run shot off lefty Tyler Anderson in a three-run sixth.