In hockey, fighting isn’t seen as a way to injure someone, like it would be in “real life”. There is a code of sportsmanship in hockey that goes beyond the rules of the game.
When that code is broken, players will square off against the offender in defense of themselves or a teammate.
For instance, it’s not a penalty to intentionally bump the goaltender after play is whistled dead, but occasionally someone will. This is viewed as especially unsportsmanlike, so one of the goaltender’s teammates will pick a fight with the player who bumped him in order to impress that behavior like that won’t be tolerated, even if there isn’t a rule against it.
Essentially, if another player is acting in such a way that is considered unsportsmanlike, he might be challenged to a fight by a member of the opposing team. A player might also choose to fight as a means to motivate his team, especially during high-tension and high-pressure situations, and especially in the playoffs.
The code of sportsmanship also extends to fighting itself. Fights are usually agreed to (sometimes in advance) by players involved, and only occur during play.
Except in extenuating circumstances, players will not fight with someone with whom they are mismatched (a 6’3″ 225lb player isn’t going to fight a 5’11″ 190lb player, unless the 5’11″ guy initiates it), and the fight is over when either of the players loses his balance or the officials interfere.
Also, fighting is technically illegal and carries a 5-minute major penalty (5 minutes in the penalty box, team is down 1 skater on the ice unless both players get the same [offsetting] penalty, in which case the teams do not lose a skater), plus additional penalties for instigating (an extra 2 minutes, team is down 1 skater [5-on-4]) and game misconduct (player out rest of the game, team is not down a skater) should the fight occur when it’s not agreeable to both players.
Typically, a fight will result in offsetting 5-minute major penalties, the players involved sit in the penalty box for 5 minutes, and the teams carry on 5-on-5 as usual.
Worst-case scenario is that one player unscrupulously picks a fight, gets a 5-minute major, a 2-minute instigation penalty, and a game misconduct so he can no longer play in that game, and his team has to send an additional player to the penalty box; the opposing player gets a 2-minute roughing penalty, which offsets the instigator, so play is 5-on-4 for 5 minutes.
In the case of the example I gave above, it would likely be offsetting 5-minute majors with no instigator because the refs will view the bump into the goalie as a reason to start a fight.