Are EVs applied to every pokemon that battled, or just the final one

//ads -- adsterra.com -- native banner
?>
As it says in my question title: In Pokemon games, are EVs applied to every Pokemon you use in a battle, or just the one that deals the final blow? I did a quick Google search but couldn't really find anything (I'm probably using the wrong search terms), so that's why I'm asking here.
And if it's the latter, to make this question more interesting: if I use Pokemon A to start the battle, then use Pokemon B where I use some kind of move that kills both the enemy and my own Pokemon, does the first one get all the EVs?
Pictures about "Are EVs applied to every pokemon that battled, or just the final one"



What are EV's and IV's? | Competitive Pokemon EXPLAINED | Pokemon Sword and Shield
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Sebastian Voortman, Gladson Xavier, mentatdgt, Miguel Á. Padriñán