A foul is called on any player or coach who makes an illegal physical or verbal action against another player as defined in the rules of basketball. When a foul is made, the other team will either get free throws or ball possession, depending on the team foul count.
There is a limit to how many fouls players and teams can commit in a game before the consequences get greater. Fouling too many times can result in a player being over the limit and fouling out. It can also put a team in a penalty situation. Being in a penalty situation results in the opposing team getting foul shots every time they get fouled.
Coaches will often pull their players out of the game before they reach the foul limit. This allows the coach to put the player back in the game if they really need them. If the coach leaves them in and they foul out, then that player is no longer an option for the rest of the game.
In the NBA, the foul limit is six player fouls per game. A player is considered in foul trouble once the player gets to four or five fouls. They will likely be benched for a while to avoid fouling out.
In college basketball, the foul limit is five player fouls per game. Players are also disqualified if they commit two technical fouls or one flagrant foul. Once a player gets three or four fouls they are considered to be in foul trouble.
In high school basketball, the foul limit is five player fouls per game. Players are also disqualified if they commit two technical fouls or one flagrant foul. Like college basketball, a player is in foul trouble if they get to three or four fouls.
There are lots of fouls in basketball. There are personal fouls, technical fouls, shooting fouls, and flagrant fouls that all count as player fouls and team fouls. All types of fouls committed by an individual player count towards their personal foul count.