"To gamify" and "to game" is not the same thing, and both can happen without relating to the real world. Don't worry, everything will relate to Stack Overflow.
What is "to gamify something"?
To gamify = to use elements of games in a non-game.
For example, getting numerical scores for actions is an element of games, but Stack Overflow is not a game. Nevertheless, Stack Overfow incorporates this game element. So Stack Overflow is gamified.
Who gamifies?
The designers of the non-game. For example, the designers of Stack Overflow choose to include numerical scores.
Why would they gamify?
Many game elements influence how people interact with the game. If you want to influence how people interact with a non-game, you can gamify it. For example, a numerical score can influence people to behave so that the score increases. The Stack Overflow designers presumably want users to ask good questions. So they arrange for good questions to give score increases.
Note that the influence of game elements on the behavior of people can be quite unrelated to "the real world". For example, achieving score increases can be rewarding even if no one else on the world knows about the score.
Ok, so what is "to game something"?
To game = to take unfair advantage of rules ignoring their intent.
For example, the intent of the score for upvoted questions is that people ask good questions. But the rule is that people get better score if their question is upvoted. So in order to game the system, two users can team up and ask lots of bad qestions and upvote the team partner's question. The get better score and more privileges, that is, unfair advantage.
Who games something?
Users of the system.
Why would they game the system?
Some common reasons:
- To get the unfair advantage (for example, privileges on Stack Overflow)
- Because gamification influences them to do it (for example, scoring on Stack Overflow)
- Because they don't agree with the system but are forced to participate (for example, tax avoidance schemes).
Why should they not game the system?
If people game the system, the original intent of the rules is not achieved.
So what's the relation of gamification and gaming the system?
See reason two for gaming the system above: Gamification can influence users of a system to game the system.
To avoid bad effects from this, one approach is to cleverly align the rules with their intent so that "game the system" becomes identical behavior to "follow the intent of the rules".
Should we use gamification anyway?
Maybe. I don't know. Personally, I like it, and I feel that it can motivate me to interact more with a site. Apart from this feeling, I don't really know whether gamification is good or bad.
For this answer, I can just point out that if a system is gamified, it can be more tempting to game that system. But this is just one possible effect of gamification, and it might well be balanced off by other effects so that gamification is an overall win.