Andrew,
Good questions, unfortunately the answer is complex. As you have mentioned headstamps, that is a good place to start. I will speak about U.S. manufactured items first.
Small caliber ammo, .50 cal and smaller is headstamped with a manufacturer's code and date. Usually the manufacturer loaded the round, produced the cartridge case and projectile, and could have purchased the powder and primer from another manufacturer. As the ammunition increases in size, the components are typically produced by a variety of suppliers, as no company typically owns all the expensive equipment and knowledge to make everything. Each supplier stamps their own identification codes and manufacturers dates on their specific product, and the products are stamped with a part number instead of a complete round identification. All of these components then come toether into subassemblies and assemblies at a government sponsored arsenal or commercial loading facility where the explosives can be better managed. The final assembly facility will typically add their identification codes and manufacturing date to the assembly with ink or paint. U.S. ammo manufacturers can be identified by MIL-STD-1461E If you google this, you will find multiple versions available off the web in pdf format. There is a 1980 version and a 1990 version.
Part of the problem with identifying larger ammo information, is that the component ID part numbers say what the part is, but not what it went into. A single model of cartridge case can be used to make up various rounds of ammo by changing the projectiles, powder, etc. If the ink is gone from the case, it's harder to tell what it was used for. Rounds like 40mm Bofors were used by multiple services. Cartridge cases for the Navy were stamped with a Mk. and Mod number, while Army and Air Force ammo was stamped with an M number for an identifier.
The description above can be roughly applied to other nations ammo. I'm sure our BOCN members can suggest other lists for German, UK, and other countries manufacturer's codes.