Hi
The CN- attacks By SN1 mecahnism. ie
1) Br- is removed and carbo cation is formed.
2)Carbo cation rearranges to form stable 20 carbocation.
3) CN- attaches to the secondary carbon.
NaOH in aqueous state is a hydrolysing agent, ie it adds OH - and replaces X where X can be CN - , Cl - etc.
4) CN is replaced from the molecule and OH is attached.
If NaOH is not aqueous it substitues H+ by Na + .
5) The salt CH2=C(ONa) -CH3 is formed which is in equilibrium.
Hope its clear to you.
Cheers!