Do stats actually get raised by Gym Badges?
The stats for a Pokémon are based on:
- The base stats
- The IV for a Pokémon (depends on the one you caught)
- The EVs gained while training a Pokémon (depends which types of Pokémon you battle)
- The nature of a Pokémon
The relevant formulas are:
and
for the first and second generation, and:
and
for the third and fourth generation.
As you can see, nowhere is there any mention of having a gym badge in these formulas.
The theory as to why the game tells you there is a stat boost that, in my opinion, holds the most ground, is that the EVs you get from battling the gym leader's Pokémon match the stat that they tell you gets raised.
Source for theory
Source for stats
The above answer is only true for link battles and generations 4 and following. In previous generations, this boost does exist and affects all in game battles. The boost is 12,5% in generations 1 and 2, 10% in generation 3.