Textbook chemistry vs Real life chemistry and impurities
Well, scientists usually purchase the purest grade of chemical available if they want to use it for a reaction. (Leading to the absurd case that the less pure reagent grade is often dismissed for the purer analytical grade.) Usually, special care is taken for these chemicals to remove especially those impurities which could hurt most — you really don’t want any palladium in your sample of sodium bromide; that could do some really bad things.

That directly leads to a second point: No chemist would ever use ‘table salt’ or tap water unless in dire need. As you state, the impurities are basically incontrollable.

With that in hand, usually chemists have a good idea of what they just added and how that influenced the reactions. But often some things still go wrong. One of the most famous examples in organic chemistry is the Nozaki-Hiyama-Kishi coupling, which was initially reported as requiring only a $\ce{Cr^{II}}$ salt — usually $\ce{CrCl2}$. However, yields of other groups were much much worse than those originally reported by Nozaki and Hiyama. It wasn’t until eleven years after initial publication that — independently of each other — the original authors and Kishi both discovered that $2~\text{mol-}\%$ $\ce{Ni^{II}}$ are required as a co-catalyst for the success of the reaction. The original chromium salt batches of Nozaki and Hiyama were obviously contaminated by enough nickel(II).

An inorganic example I once heard of in a solid state chemistry course was a crystal structure published with experimentals in a solid state reaction. (I can’t remember the exact compound.) Other authors tried to reproduce the reaction but got much worse yields than the $100~\%$ that are expected in solid state reactions. The solution was that the square unit cell contained a hydride anion in its centre, almost invisible due to its low electron density. This hydride was introduced to the reaction from the silicon grease the authors used for the glass joints.