why doesn't alcohol react with sodium hydroxide but react with potassium hydroxide?
The reaction of alcohol + NaOH producing $\ce{C2H5ONa}$ + water is an equilibrium which is usually strongly pushed to the left hand side. But in the presence of $\ce{CS2}$, the alkoxide $\ce{C2H5ONa}$  is transformed into xanthate. So the equilibrium is driven to the right hand side.