No real hard & fast "rules" for this subject.
For pistols which I shoot & use fairly frequently, I like to have 5-8 magazines. 1 primary & 1-2 "spares" (carry); 1-2 for range/training use and 1-3 repair/replacement mags.
For pistols which see less heavy training & practice, I like to have 3 mags. 1 primary, 1 carry spare and 1 repair/replacement mag. (I'm talking about my LCP in this instance.)
Those are working "minimum" numbers, and I've certainly accumulated more than that for a number of my pistols.
Magazines are "assemblies" made up of
parts. Sometimes one or more of those
parts may require attention in the way of replacement. Typically, this may be the mag spring, as it becomes too weak for reliable functioning, but sometimes it might also be a follower, butt-catch or butt plate (sometimes also called inserts, floorplates, etc, depending on the gun company).
Once the mag body itself is damaged or becomes worn, then the whole mag needs to be tossed and replaced. Damaged, deformed mag lips are an example of what would usually result in a mag being discarded and replaced.
I've had some mags last for many years, except for periodic spring replacements (and an occasional follower), and then some which became suspect and were simply discarded and replaced. Dropping mags on hard surfaces, like concrete, can damage them, especially if it damages the lips.