When a player is fouled while shooting, he has the right to shoot free throws worth 1 point each. If the player was fouled during the act of shooting a three pointer, he will have three free throws, while if he was fouled while shooting a two point shot, he will have to free throw attempts. If the fouled player still manages to somehow make the shot despite the physical contact by the opponent, he will shoot only one free throw, while adding the field goal's points to the scoreboard.
That way, the team that trails hopes that the free throw shooter misses the free throws. That allows them to get the ball back without burning the clock. However, most of the time players make the free throws; still the strategy is valid, as they will seek to add three points to score while only allowing two points maxilum, that way making the point difference smaller.
Don Nelson, the head coach of the Dallas Mavericks from 1997-2005, first applied hack-a-shaq against top player Shaquille O'Neal, who although was a remarkable basketball player, was also a remarkably bad free throw shooter. With hack-a-shaq, players purposely fouls a particularly bad free throw shooter. That stops the opponents offense while exploring an opposing player's weakness. Hack a Shaq is sometimes used at the middle of the game, which leads to a lot of stopping, making the game boring. Because of that, the hack a shaq strategy is not very liked by basketball watchers.
For the 2016-17 NBA season, the NBA introduced a rule that gives any team that is fouled one free throw and possession of the ball if the foul is made in the last two minutes of the 4th quarter or overtime. This rule is designed to prevent strategies like hack-a-shaq.
Fouling rewards the other team with free throws. The rewards improve as teams foul more. Teams enter penalty situations, like the bonus and double bonus, which gives them additional free throws every time a player is fouled.
REMEMBER: The double bonus is only in college basketball.
If you want to learn more about penalty situations, check out Basketball Penalty Situations.
When deciding to purposely foul, you should consider the following:
Team A has can let the game clock hit zero with just dribbling. Team B needs to get the ball back to even the score. To get the ball back Team B has two choices:
Stealing the ball is harder than fouling and doesn't guarantee possession. In this case, Team B should foul. It is possible that Team A makes a free throw, but it remains a one possession game. Team B gets the ball and can tie the game if they make a three-pointer.
If you want to learn more about the types of fouls in basketball check out these tutorials: