The magazine is a storage device designed to hold cartridges prior to insertion into the firing chamber. It is important to know what type of magazine your gun has to ensure you properly load and unload prior to usage, storage or cleaning. The location of the magazine will vary depending upon the action, model, and make of the gun. Various types of magazines exist but the two most common are: box magazines and tubular magazines.
Here is a cutout of a box magazine for the Glock handgun:
This is an example of a 'double-stacked' magazine due to the cartridges being stacked side by side as illustrated above. AR-15 and AK rifles also use double stacked magazines. Most pump shotguns have a tubular magazine attached to the bottom of the barrel. Some shotguns, such as the Saiga, Vepr, etc. use box magazines. Some bolt rifles have an internal box magazine but some models have detachable magazines. Many 1911 .45 ACP (automatic colt pistol) handguns use a 'single stack' magazine where the ammunition is stacked on top of each other, hence the name single stack. In the picture below, the single stack magazine is on the left. As you can clearly see, the single stack magazine is much slimmer than the double stacks. There is one big benefit of using single stack magazine fed handgun; the handle is slim and can be held by smaller hands more effectively. The biggest drawback of single stacked firearms is the capacity. The .45 ACP 1911's usually hold 8 rounds which limits the amount of ammunition in the handgun. Other comparable .45 ACP handguns that are double stacked, such as the Glock 21, holds 13 rounds.
The most important lesson in magazines is get the right one for your firearm and choose the manufacturer's brand or other reputable companies such as Magpul, Mag-tec, Lancer, etc. There are cheaper brands such as Promags, Thermold, and others that are to be avoided. These companies are not quality and many of their products are not reliable. A firearm is only as reliable as their action parts. You can have the most reliable gun in the world but without a reliable magazine or ammunition it won't run properly.