If you max out a stat and then defeat a Pokémon that gives EVs in that stat, those new EVs are thrown out and have no effect on your EV total. As sumwun mentioned, though, the cap per stat is 255, even though the most that can be used is 252, wasting 3 EVs. If you’re new to EV training, I wouldn’t worry too much about it; if you max out 2 stats to 255, you’re only missing out on 6 EVs (2 of which will always be unused), which really isn’t enough to matter much at all.