When it is a close game, the team that is losing starts going crazy and they start fouling like there's no tomorrow.
Your observation is correct, but just for clarity, isn't actually that the other team is going crazy or being rough, it's just common strategy. In reality, when a team is down by a few baskets late, they will start fouling to get the other team on the free throw line (typically by just running up and tapping the opponent with the ball). This stops the clock, preventing the leading team from holding the ball for the whole shot clock and taking up more time. The trailing team will foul on purpose so that the leading team goes straight to the free throw line. Hopefully the leading team misses a shot or two, then the trailing team rebounds or inbounds and pushes the ball to tries to score as fast as possible. If the leading team is missing their free throws and the trailing starts hitting well (especially from three), then it's easier for the trailing team to come from behind and win.
It's just hard to see that on buzzerbeater since we are just watching X's and O's. I'm sure most on here knew that, but wanted to be helpful and clarify for managers in countries that may not be as familiar with the sport.