
In these reactions between alkyl halide and KOH in different states the product is different only because of the change in state of KOH from aqueous and alcohol .
Can someone explain the mechanism which causes this drastic change?

In these reactions between alkyl halide and KOH in different states the product is different only because of the change in state of KOH from aqueous and alcohol .
Can someone explain the mechanism which causes this drastic change?
Nucleophilic substitution always competes with Elimination reaction in such cases.
What is the difference between them?
In alcoholic solution the $\ce{KOH}$ is basic enough ($\mathrm{pK}_{\mathrm{a}}$ 15.74) to deprotonate a small amount of alcohol molecules ($\mathrm{pK}_{\mathrm{a}}$ 16–17)), thus forming alcohlate salts $\ce{ROK}$. The alcoholate anions $\ce{RO-}$ are not only more basic than pure $\ce{OH-}$ but they are also bulkier (how much bulkier depends on the group $R$). The higher bulkiness makes $\ce{RO-}$ a worse nucleophile than $\ce{OH-}$ and the higher basicity makes it better at $\mathrm{E}2$ eliminations.