IVs and EVs are separate. A man in the Pokémon Center in Kiloude City (post-game) will tell you whether you have perfect IVs in any given stat category. He'll say those stats "can't be beat." IVs are set from the moment a Pokémon is caught or hatched, and cannot be changed. Their a number between 0 and 31 and determine stat growth. There's an IV for each stat category. 31 is perfect and ensures highest stat growth.
While you can't change them, you can eventually pass them on via breeding. A Pokémon holding Destiny Knot while breeding will ensure five IVs across the two parents will pass onto the child. So you keep hatching until you have a child that gets the good IVs from their parents. Then you breed that with another Pokémon that has the good IVs you're still missing, using Destiny Knot again to pass on five of the parents' IVs. Eventually, you'll get the good IVs you already have plus the ones you didn't.
EVs are different and can be distributed freely by the player, up to 510 EVs total. You get EVs by Super Training (hit the R button to scroll to the Super Training screen), or by battling Pokémon, each Pokémon giving a certain EV point. The most efficient way is Horde battling, using Oddish's Sweet Scent to lure them out and then OHKO everyone at once with moves like Surf or Earthquake. Equipping the trainee with a Power Item for the stat being raised increases the EVs received by 4 per Pokemon.
For every four EVs in a stat category, that Pokémon gains an extra point in that stat at lv. 100. Super Training stops you at 252 EVs per stat category since 252 is divisible by 4 and there's no benefit beyond 252. Thus, if you keep doing the Attack minigame in Super Training until it says your Attack is maxed out, or if you keep doing Horde battles for Attack points until your Super Training graph says the same, your Pokémon will have an Attack stat about 63 points higher at lv. 100.
Most people invest 252 in one category (by training in Super Training until it stops adding points in that category), and then 252 in another category, and then the remaining 6 points wherever (usually HP).
You do this in conjunction with nature. Each nature (except the neutral ones) will make one stat grow more, and one stat grow less. So usually you look for a Pokémon with the nature that grows the stat you plan to use a lot. If I'm raising a Pokémon that will only use Special Attacks, but never use Physical Attacks, I'd use a Modest Pokémon (+ Sp. Attack, - Attack). Then I'd invest EVs into his Sp. Attack, most likely, to get the most power out of it.