This could help you out a bit.
Basically, Game Freak had it programmed into the game that when you defeat a Pokemon, it would give you a certain number of EV's in its best stat (however, there are some cases where a Pokemon gives you EV's for a stat that is not its highest). EV's help you train your Pokemon in its stonger area's, so you wouldn't be randomly boosting a Shedinja's HP while you can raise its attack instead.