Bayern had been held to three consecutive 1-1 draws in the Bundesliga, but ended its winless run with an emphatic 4-0 crushing of Mainz to reach the DFB-Pokal quarter-final.
Manchester City loanee Cancelo started the game, just a day after joining the German champion, and assisted Eric Choupo-Moting's 17th-minute opener with a pinpoint right-wing cross.
Nagelsmann was unsurprised to see wing-back Cancelo flourish on his first start after working under former Bayern manager Guardiola.
"Joao played a very good game. He was very creative, played some great passes and crosses and also made very good deep runs," Nagelsmann said. "He was playing under one of the best managers in the world. I just told him to play his game and not to think too much."
Jamal Musiala and Leroy Sane added first-half goals soon after Choupo-Moting's header, before substitute Alphonso Davies secured victory in the latter stages.
Victory marked a significant improvement to Bayern's post-World Cup form, as Nagelsmann hailed an "important" first win in 2023.
"I'm very satisfied with the result and the way we played," he said. "Games against Mainz and Bo Svensson's teams are extremely difficult.
"We were more aggressive with the ball going forward than in recent games. We defended well and kept a clean sheet which was important.
"It was a deserved and important win, not only in this competition but also after we failed to win our games since the start of the year. We want more of the same against Wolfsburg on Sunday."