In Role Playing Games
Players, NPCs, and Party Members
In most RPGs, death occurs from being killed by an opponent, failing a task, or death from lack of resources, such as starvation. In common modern Action RPGs, a killed character would not stay dead. Most of the time, they would simply lose items, some of their money, or Experience. They would respawn in a village, city, or town near the area that they died in. In more old-fashioned 'Rogue' type RPGs, or Pen-and-paper RPGs, the characters would stay permemently dead once killed, unless resurrected. Sometimes, your character or other NPCs in an RPG have to die to continue the plot of the RPG.
Most enemies in RPGs die from the player or his/her party members killing it. In some RPGs, the enemies can die from traps either originally there or set up by you. Bosses are sometimes killed during a break form actual gameplay where a character sacrifices him/herself to kill the boss. This almost never happens with normal enemies.
In Strategy Games
The death of a unit in a strategy game always occurs from enemies destroying it one way or the other, or some natural hazard within the map of the strategy game. Their death is usually not important, as the player can always create new ones, unless they are special units who stay dead once killed.
Players, NPCs, and Team Members
In Shooters, you, your team, or NPCs are mostly killed by the enemie's attacks. Sometimes a death of a Team Member or NPC is inevitable, as it contributes to the plot. In most Shooters you or your team members could also be killed by hazardous substances in the game, falling from long distances, or friendly fire.
Enemies are killed by you and/or your team, if you have one.
In Other Types
Player, NPCs, and Other Friendlies
In other types of games, you, friendlies, or NPCs can be killed in several ways, whether it's from the enemy simply touching your player or a friendly, as in several platformers, or by crashing your racecar into some random wall, or whether it's purposely inevitable
They are usually killed in other types of games by being jumped on, crashing, and many, many other things.