Why ammonium hydroxide precipitates metal salts? When I was going through the chapter on pnicotgens, I got to know that ammonia acts as a Lewis base and it dissociates in water giving out hydroxide ion and the further hydroxide of ammonia, which we refer to as ammonium hydroxide, precipitates metal salts in a form of metal hydroxides.

I want to know the reason why this thing happens. According to me, ammonium hydroxide should form a complex with the metal being a base after donating a pair of electrons. Correct me if I am wrong. A reaction is given below as an example of a reaction between ammonium hydroxide and zinc sulfate:

$$\ce{ZnSO4 + 2 (NH3 * H2O) → Zn(OH)2 + (NH4)2SO4}$$
It's simply because of the concentration. In aqueous solution, the formation of a precipitate is favored over the formation of a complex ion, and it can be shown using solubility equilibria and $K_\mathrm{f}$ (but it won't be pretty).
This is just like the QA test for copper(II). After a small amount of aqueous ammonia is added, $\ce{Cu(OH)2}$ is observed. Add more, and you get the deep blue $\ce{[Cu(NH3)4]^2+}$ complex.