Pokemon, once they are old enough, go out of their way to attack trainers to become stronger, either knowing that trained pokemon give more experience or hoping the trainer will accept them as aprentices. Pokemon have to agree to be captured, damaging them or even putting them to sleep only serves to prove to them that the Pokemon under the trainer's guidance become powerful, convincing them to accept. Pokemon can sense their surroundings while inside the pokeball almost as if they were there, but the pokeball allows them to save energy for when they need it. Masterballs are abominations that should be destroyed.
After a wild pokemon faints (or experiences near death according to the japanese versions), it eventually comes back to its senses having gained lots of experience from the fight. Trainers' pokemon have the disadvantage that they can only gain experience when they win, because they are inmediatly returned to the pokeball where they are kept in stasis until they are restored in a pokemon center.
Fainted pokemon are almost never attacked by predators because they would be exposed to trainers under unwanted circumstances, either while starving or while eating or with a full stomach. Pokemon do their normal living stuff, like raising their babies, deep in the wild where we can't reach in the games, trainers are forbidden from entering these areas for preservation stuff. Stronger pokemon like evolved ones also live in these ares, not needing to attack trainers because they are already strong enough or would rather stay and protect the young; this is why we don't encounter most evolved mons in the wild.