For example, there is no such rule which states a player cannot get in contact with opposing team’s goalkeeper in goalkeeper’s 6-yard box. However, in the local league, the referees gives a foul agaisnt the attacking team even if goalkeeper fouls the attacker inside defending team’s 6-yard box. I guess, the reason for such thing is, the coaches, players, and fans usually expect such a foul call after a physical contact with goalkeeper and attacking team’s player inside the 6-yard box. So, as shown in the example, can match officials take decisions which are not written in the book but seems correct in a common sense?
No, they can't. Every call must be made according to the rules.
However, some rules have room for interpretation. For example:
- not every physical contact is a foul
- challenges can be be risky for both players
- playing in a dangerous manner (what actually IS dangerous?)
In your example the 6yd box used to be the goalkeeper's area years ago and it was not permitted to challenge the goalie in there. Referees often still call challenges against the goalie against the attacker, primarily because the attackers endanger the goalkeeper. Or they simply do, because the keeper already got their hands on the ball. From there on it's no longer allowed to challenge them. Without visual evidence it's hard to tell why a certain call has been made.