It's not metagaming. The whole concept of character levels is about simplification. In much the same way that the Navier-Stokes equations can be simplified down to Bernoulli's principle by making certain reasonable assumptions, we can use levels to represent the progression of a character by making certain assumptions about how they act.
Your bonus to various skills should only increase via adventuring because we assume that you're using those skills in the course of the adventure. In practice, this tends to work out, because players are less likely to invest in diplomatic skills if the campaign doesn't call for them; and even if they did invest in those skills, they're unlikely to affect much in that game. When choosing how to simplify our model, it's not a major loss if things get weird around situations that don't actually occur.
Note that this whole premise only holds from about 2E and onward. Prior to that, the D&D ruleset wasn't much concerned with the concept of role-playing. For whatever else he may be credited, Gygax was clearly more interested in challenging the players, and possibly telling a cool story, than with presenting an internally-consistent world. If you read back through the Basic rules, he is quite insistent upon that point. It wasn't until he was removed from the project that D&D really became a role-playing game, in the modern sense of the term.