J.R. S. answered 12/01/22
Ph.D. University Professor with 10+ years Tutoring Experience
It is just like a displacement reaction, but as with other displacement reactions, not all metals can displace all other metals. This is why we have an "activity series" for metals. Metals like Li, K, Na, etc. are near the top of the list being very active/reactive, while metals like Ag, Pt and Au are near the bottom of the list being rather inactive/unreactive.
So, the reactive metals will tend to react with base (OH-) to form a salt and hydrogen gas. The non-reactive metals will not do so.