The visitors, though, were the first side to take an attempt on goal when Joselu's shot going just wide on 11 minutes.
Ten minutes later Szalai put Mainz into the lead, heading home Junior Diaz's cross from close range.
The Hungarian striker came close to adding his second five minutes later when he attempted to shoot on goal from outside the box, but it was blocked.
Mainz eventually doubled their advantage and their second goal came just seconds into the second half, Szalai firing in from outside the Hoffenheim penalty box.
The 24-year-old completed his hat-trick in the 64th minute when he headed in Muller's delivery from just yards out.