Since $\mathrm{p}K_\mathrm{a}$ of $\ce{HCN}$ is 9.21 (Wikipedia), the cyanide ion in water is pretty alkaline and contains significant amounts of hydroxide ions, according to the following equilibrium:
$$\ce{NC- + H2O <=> OH- + HCN}$$
That's why you smell strong $\ce{HCN}$ in aqueous $\ce{KCN}$ or $\ce{NaCN}$ solution. Thus, when you perform the reaction of $\ce{KCN}$ or $\ce{NaCN}$ with the haloalkane (including allyl and benzyl) in water you tend to get the substitution by $\ce{^-OH}$ instead of $\ce{^-CN}$. To get major product as cyanoalkane, you may need to do the reaction in absolute alcohol.
Not relevant, but note worthy that $\ce{^-CN}$ is an ambident nucleophile, meaning a nucleophile which can attack acitve site of a molecule through more than one sites (here either by $\ce{N}$ or $\ce{C}$). Thus, a reaction of alkyl halide ($\ce{R-X}$) with $\ce{KCN}$ gives alkyl nitrile ($\ce{R-CN}$) while a reaction of alkyl halide with $\ce{AgCN}$ gives an alkyl isonitrile ($\ce{R-NC}$).