So long as you’re engaging in league-sanctioned battles or battles against wild pokémon, they’re perfectly safe. There are strict rules within every pokémon league that prevent trainers from killing or seriously injuring opponent pokémon. It’s like boxing or wrestling: in legitimate matches, you absolutely cannot do permanent damage to your opponent, as any more than that constitutes manslaughter or even murder. The same concept applies to league-sanctioned battles. While you can’t be blamed for acts of God (although in some cases, the architect of the stadium might be), if you consciously attempt to disobey the referee and continue the match past the point where your pokémon or your opponent’s has fainted, you could be arrested after the battle if anything serious happens. However, if you engage in a league-sanctioned battle, you will either do so under the watch of an official referee (who will always call the match before any serious damage occurs), or you will outline the rules to a fellow trainer beforehand (so the both of you enter a verbal agreement to fight while following league regulations).
As for wild pokémon battles, wild pokémon typically have no interest in killing other pokémon except in extreme cases of self-defense. Wild pokémon are intelligent enough to recognize when an enemy has been incapacitated, and thus, they will leave you alone if you make it apparent that you won’t harm them after the match is over. (Note: For the most part. Some of the more aggressive pokémon or pokémon who believe you’re trying to kill them will make an attempt on your life and the lives of your pokémon, so it’s a good idea to exercise good judgment while in the wild. Do not, for example, attack a singular spearow, as spearow are just ornery and violent enough to call the rest of their nearby flock to attack you back.)
That having been said, there are also underground pokémon matches, or battles between trainers in settings that aren’t exactly by-the-book. You’ll know when you’ve found such a place when trainers never outline rules to one another or when large crowds gather to take bets on the matches. These matches are usually done to-the-death, and thus, they’re far less safe for either the pokémon or the trainers involved. Needless to say, they’re highly illegal and frowned upon by most societies, but due to their underground, secretive nature, it’s difficult to prevent them from occurring. The best advice I can give you regarding these is never battle in an arena unless you know for certain that it’s league-approved, and certainly don’t battle against a trainer who agrees to league rules beforehand.