If the author discovers it (that is fairly common) he will publish an erratum. It happens. More often there is a gap and you fill it. If another person discovers it, he will generally notify the author and the latter will publish a correction. Or you can just publish it. I have a paper titled, “On an error of X”, where X was a world-famous philosopher-logician. I didn’t even discover it, but original claim was so badly described that it was virtually impossible to work out what was intended. In one interpretation, the claim was wrong and the person who discovered it showed me a counter-example. On another interpretation, the claim was correct, but the argument given was so bad it was fatuous. The Proof I gave was fairly complicated.

Here is a much more interesting incident, much closer to the OP. There was a “theorem” published in, I think, the forties. IIRC, it was called Hamburger’s theorem, but I could be mis-remembering. It had been used extensively, so I was told. About 25 years ago, a colleague of mine who was an expert in the area got a letter from a student in Denmark saying that he had been unable to follow the original proof and, in attempting to find a proof, had found a counter-example! My colleague read it carefully and agreed with the student. The student ended up doing a PhD with my colleague and is now a professor in Copenhagen.

I do not know what happened to the people who, over the years, used it without, evidently, verfying the proof.