For a Pokemon to have the maximum in a stat, it must have:
- 31 IVs in that stat.
- 252 EVs in that stat.
- A positive Nature in that stat. (stats other than HP only)
- On the +6 stage of the stat due to stat modifying moves like Swords Dance. (In-battle only, stats other than HP only)
- Holding an item that boosts the desired stat. The item that boosts it the most variates in many cases. (only effected in battle)
- The Pokemon is level 100. (credit to MiniNinetales)
All of the above works for your Pokemon's offensive stats.