The reason that they did this is that a very smart researcher discovered that the majority of stomach ulcers were not caused by stomach chemistry per se, but rather were caused by infections, specifically from a bacterium (Helicobacter pylorii). Prior to that discovery, acid blockers were a primary treatment for chronic ulcers, and drug companies could count on selling them to each ulcer patient for years and years. After that discovery, anyone who went to a doctor with a stomach ulcer would get it cleared up in two weeks or so with a course of antibiotics.
So what were the drug companies to do with their prescription acid-blocking drugs? They took them OTC, so they would be available to anyone with stomach pain without a doctor visit.
Yes, they're effective. Yes, they still make the drug companies a lot of money. Best for the patient? Not hardly.