Gomez, last season’s Bundesliga top scorer, converted a 37th-minute penalty and added another 10 minutes after the restart when goalkeeper Kevin Trapp saved the striker’s second spot kick but he tapped in on the rebound.
The Germany international completed his hat-trick, firing in from close range after a Thomas Mueller cross as Bayern, without injured Arjen Robben, kept a clean sheet for the fifth consecutive game in all competitions.
Werder Bremen snatched a late 2-1 win at Hoffenheim thanks to a goal by Markus Rosenberg and moved up to nine points, in second place behind Bayern on goal difference.
Freiburg piled more misery on 2009 champions VfL Wolfsburg, crushing them 3-0 for their third straight defeat and leaving them on three points from four games in 15th place.
Hamburg thought they had ended their own bad run when they led twice against Cologne but they had to suffer their third loss in four games when the visitors grabbed an entertaining 4-3 victory with two goals in the final six minutes.
Champions Borussia Dortmund can join Bayern on nine points if they beat fellow Champions League competitors Bayer Leverkusen later on Saturday (1630 GMT).