There's a clickbaitily-titled "Smartest '1000 IQ Plays' in Sports History" video on YouTube. The second and fourth clips in the video both have American football players apparently trying desperately to keep the ball out of the end zone, and instead to down the ball just before the end zone. Would they not score a touchdown if they got the ball in the end zone?
So there are really 2 things happening regarding to your question: what you're asking, and what those players are actually doing, which is very different than what you asked. I'll explain both situations. But a summary would be that those plays linked are not about a team avoiding a touchdown.
In general as a team you want to score as many points as possible, but in reality, you only need to outscore the opponent, no matter how many points they've scored. You want to always be in a position that gives you higher chance of winning, which is usually, but not always, synonymous to having the most points.
So when do you want to not score immediately? Based on the last statement of the previous paragraph, whenever it gives you a higher chance of winning. Imagine the score is tied at 24 a piece. Your team has the ball at the opponents 10 yard line with 1 minute to go on the first down. If you score a touchdown on the very next play, the opponent has a chance to score back in the next 55ish seconds left on the clock to tie the score. They could be aggressive and go for the 2 point conversion and try to win, or take a more conservatice approach to go to overtime and try to win there. Either way you have left the door open for the oponent to win. On the other hand, you could run the clock down close to 0 seconds left, and try an easy chip kick to win the game with the opponent having no chance to get the ball back. Same tactic is used when the team is 1 or 2 points down too, it just marginally of a higher risk as missing a kick could result in a loss. So in that case, coaches will go for run plays where time doesn't stop, instead of a pass play where there is potential of stopping the time clock on incomplete passes. Here is an example where a teams is actually leading, but the Rams stop from scoring immediately to avoid any scenario of letting Aaron Rodgers and company produce yet another miracle win, although it would've required 2 scores, and an onside kick recovery all just under a minute which even by their standards would've been highly unlikely.
As real and strategic these situations are, this is NOT at all what the plays in the video you linked are about.
Those 2 plays are the tail end of punts. If the ball hits the endzone, it results in a touchback, and the ball will be placed on the 20 yard line. Notice the ball has to either hit the endzone ground (including the goal line), or a player that is touching that area has to touch the ball for a touchback to occur. This is clearly worse than having your opponent anywhere between the 20 yard line and their endzone.
Now watch those plays again. In the first one (See full play here), two Patriot special teams players make diving "saves" to not let the ball hit the endzone, and then a third player downs the ball around the 1st yard line. Thus, the Patriots pushed backed the Steelers 19 yards had they let the ball bounce in the endzone. In a playoff game, plays like this can be the difference between playing a game next week or watching it from home. Similarly, in the second play a Buccaneer stops the ball from bouncing in the endzone, passing it back where it's recovered by a teammate inside the 1 yard line. So the point of those plays were not avoid scoring, but rather pushing back the opposing team. Which means they need a longer drive to score, and also significantly increases the chance of scoring a safety on the defensive side.
They would not get the touchdown since this play is during a kickoff and the Patriots are the kicking team. If the ball hits the ground inside the endzone, it would be a touchback and the receiving team would have the ball on their 25 yard line. The Patriots are trying to limit the gain of the receiving team and, therefore, are keeping the ball outside of the endzone to give the receiving team a bad field position.