I haven’t had an insurance claim on this in years (thank you H2O2 !!) but my salespeople commonly tour facilities cleaned by competitors or in house crews where someone has spilled bowl cleaner, glass cleaner, or bleach on the carpet immediately outside the bathroom or the janitor closet.
There are carpet dyeing companies who specialize in bringing back the original color.
Here’s the process.
As the article says, there are a number of causes, but most can be fixed for about one third the cost of replacing the carpet.