The Serie A leaders were 2-0 up going into the second half, courtesy of goals from Paulo Dybala and Mario Mandzukic, but Abdoulay Konko and Emmanuel Latte Lath scored either side of a Miralem Pjanic penalty to set up a tense finish at Juventus Stadium.
In the end holders Juventus held on for a win that sets up a quarter-final against Milan or Torino, but Allegri warned his players that they must play to the whistle.
He told Rai Sport: "It was a good performance from both teams. Unfortunately we kind of stopped playing and at the end and ran a huge risk of conceding a third goal.
"At that stage it would've made qualification really tough, as Atalanta found confidence and were pouring forward.
"This type of match does us good, because we have to learn that the game isn't over until the end and we've got to avoid these errors.
"I can understand the opposition being fired up, but I won't accept us taking our foot off the gas. We ran a really big risk. The games aren't over until the final whistle."
Allegri's confidence in his side's ability to win the game was evident from the outset, given star striker Gonzalo Higuain's place among the substitutes, but Atalanta's Andrea Conti was allowed to get in behind the Juventus defence with ease and cause havoc as the game wore on.
Allegri insisted Atalanta's goals could have been prevented, saying: "We need to get it into our heads that you attack when it's time to attack, then you defend when it's time to defend.
"We've got to reflect, because this seems to happen to us a lot now, at least once a month.
"When the game looks like it's safe, we have to keep a clean sheet. We defended badly on the goals, but other than those we didn't really need tough saves.
"Atalanta had pushed forward, but if we defended in an organised and determined fashion, we wouldn't have allowed them to score."