Quoted By:
Can't think of a good way to explain it.. When training in EV's your Pokemon becomes resistant to the type of the Pokemon you fought when the EV you trained in is maxed. For example, you're training a Ralts in HP against Gulpin and the EV is maxed. Ralts now has a resistance against Poison. This'll only work if the pokemon does not already have that resistance or immunity.
..or you could take it to some guy and he gives it a resistance OR.. It's determined randomly when you catch/breed it..