To answer this question, we need to understand the intent or perceived intent of the player involved. Rules in all sports are to keep each game fair and safe. If ever a player initiates contact intentionally to intimidate or harm an official, they will be ejected from the game. In most hockey leagues, this ejection is also followed by suspension from future games. League commissioners assess the severity of the offense and determine how long the suspension will last. In the NHL, there are also fines given to players that are aggressive towards on-ice officials.
If contact with an official is accidental, there is no action taken against the team or player involved. If there is an injury to an official, play is stopped and medical attention is given where needed. Contact with a referee happens in most games as players are always trying to find open ice to move and play. To keep play in front of them, officials are always moving. Players are constantly keeping track of open ice, puck location, and their offensive or defensive positioning. Officials movements are often forgotten or not noticed by players as the puck moves around the boards. Officials are allowed to verbally remind players where they are on the ice. This helps players try to move the puck or direct play away from the referees.
Strategically, players often try to use linesmen and referees as barriers to lose defenders chasing them. This is still not going to cause disciplinary action against players. Officials are trained to place themselves in areas of the ice that will keep them out of the flow of the game more effectively.