This isn't a glitch, it's just how Arma 2's ammunition system works. The wiki contains more information:
Many FPS players are used to pool-type ammunition systems (e.g. in Left 4 Dead), which refill the current magazine directly out of an unsegregated pool of bullets. Arma 2 uses a more realistic magazine system. [...] You can only change magazines; you cannot refill them. When you reload, you place the fullest available magazine into the gun.
Try to fully expend your magazines if possible before reloading. Near-empty magazines still take up as much inventory slots as a full one, so mind your reloading. Let's say that you begin with a full Makarov PM (8 rounds) and two spare magazines. You shoot 4 rounds and reload. After the animation is complete, one full magazine is in the Makarov, while one full magazine and one half-full magazine are in your Inventory.