The Bavarians equalled a Bundesliga record of 36 games unbeaten, dating back to a 2-1 home defeat to Bayer Leverkusen last October, with a hard-fought win at the Rhein-Neckar Arena, but the Spanish coach said it was not a particularly strong performance from his unbeaten side.
Niklas Sule became Hoffenheim's youngest-ever goalscorer when he opened the scoring in the first half, but Franck Ribery brought Bayern level six minutes before the break with a free-kick which took a deflection off team-mate Mario Mandzukic on its way in.
Thomas Muller then snatched victory for Bayern with 15 minutes to go as the Bavarians returned to the top of the Bundesliga.
"It certainly wasn't our best performance, but we've won at least," he told his club's website.
"Not everything worked perfectly so we're going to have to change the way we play.
"Games against Hoffenheim have always been tight in recent years, but we had that bit of luck."
Guardiola's counterpart Markus Gisdol admitted his side needed that luck if they were to get anything from a game he was nevertheless satisfied with.
"We were on a par with Bayern, but if you want to cause them more problems, then everything has got to be perfect," he said.
"You can't afford to concede a goal from such a deflection, for example. I've got mixed feelings. On the one hand, I'm happy because we had Bayern on the ropes, but on the other hand, we're left empty-handed."