The M9 is a military specification of the Beretta 92F. The pistol fires 9x19mm rounds. The M9 replaced the M1911 pistol as the U.S. military's pistol of choice in 1985.
The M9 frequently appears in video games due to its mass-market appeal in real life. It is relatively well known, it's mass produced, and, in addition, it's a reliable handgun. Its adoption by many armies across the world is representative of its success ahead of other firearms. Its default 9mm ammunition is also reliable, accurate, and powerful. While many video games often do not specify what handgun a protagonist is using (typically a handgun is just called a "handgun"), more often than not the handgun is based on the M9.
The features of the pistol often change from video game to video game, often depending on the experience of the design team. Another factor which contributes to the differing appearances of the M9 is that the pistol has many variations in real life. The 92 series alone, for example, can have a 10, 15, 17, 18, or 20 round magazine. Games which put the M9's magazine size below 10 rounds or in the 30 round range are incorrect, but this can be put down to the many variations of the pistol and its place in popular culture and folklore. It could be said to have a similar status to that of the Desert Eagle.
Military video games typically accredit the M9 much more correctly. The M9 appears in a range of games - from Metal Gear Solid 2: Sons of Liberty, to Tom Clancy's Ghost Recon Advanced Warfighter 2, to Max Payne 2: The Fall of Max Payne. Over the years, then, it has very much become the "default weapon" in video games.
It should also be noted that the Beretta model featured in Call of Duty 4 : Modern Warfare and Call of Duty : Modern Warfare 2 are not Beretta M9 pistols. The Beretta M9 is the military designation of the Beretta 92F and the Beretta 92FS. The pistol featured in the Modern Warfare series is the Beretta 92SB, an older Beretta model with a round trigger guard.