This is the one aspect of soccer that I wish could be improved. There’s so much subjectivity in calling fouls, in determining whether there’s a card, and deciding whether it’s a red or a yellow.
I don’t know how this could be avoided, except that maybe matches could be reviewed (after the match) and each referee given a numerical score rating whether they were consistent in the criteria they applied for calling fouls on each team and player. This wouldn’t be perfect, but at least they would know someone was watching their performance. It would also make it a bit more difficult for referees to be involved in match fixing.
It's a problem in most sports, especially football and basketball.