I agree that the issue is safety. When I was in high school the state banned the use of 15 passenger vans for team travel. This was just after the crash that wiped out the Wyoming U cross country team. It is a good rule that keeps kids out of rollover prone vehicles.
DQing for shaving is like DQing a team that shows up in a 15 passenger van. It has nothing to do with the athletic performance.
The appropriate response by the coach or whoever saw the offending action would have been to take the razor (so it can't be shared) and punish the athlete in a way other than DQ.