So how do you get the EVS? Well, EV points are actually a hidden resource- but they behave like XP. Each time your team beats a pokemon in battle, all of your pokemon that are conscious at the end of the fight that participated against that opponent- even if they only appeared in the battle against that foe for just a moment- gain XP. Similarly, all of those pokemon will gain EV points for the pokemon that you fought. However, EV points work a bit differently from XP.
To begin with, the amount of EV points gained from a pokemon never changes. A Pidgey is worth one Speed point, and will always be worth one Speed point, no matter what level the pokemon that fought it was, no matter how many pokemon you fought it with, and even if it’s level 100. Fortunately, that Speed point does not get divided amongst the pokemon that fought it- instead, each pokemon that fought that Pidgey will gain 1 Speed point.
Because of this, there is no actual slowdown in EV point gain for ‘flashing in’ a pokemon, and in fact it can save you a lot of time and difficulty in training your pokemon to do so.
As for which EV Points are gained from fighting what- well, there are plenty of guides to that. If you don’t feel too much like looking them up, then remember this- EV points were installed in the game to reflect a pokemon learning from its battles. If your pokemon fights a lot of things that are fast, it will likely be gaining a lot of Speed EV points. If it fights a lot of things with high HP values, it will gain a lot of HP EV points, and so on.
Because of EVs and how they don’t relate to XP at all, sometimes it will make more sense to linger in an area for a while, having your pokemon drastically outlevel the local wild pokemon- but make huge gains in EV points that will be well worth it later when they turn out more focused in their stat development.
Now, each pokemon you fight will give somewhere from 1 to 3 EV points to the pokemon that fought it. How exactly this is determined I’m not sure, but generally a more evolved opponent will give more EV points. Unfortunately, these EV points are not always all in the same stat- so again, you’re going to want to look this information up. I won’t provide it to you here and now, but that’s mostly because there are so very many sources you can get the information from so easily that it’s not worth worrying about- yet. I think it’s much more important to know what you’re doing with the EV points, which a lot of people have a lot of opinions on and which doesn’t get discussed nearly enough in online articles that you can look up.