KCN being ionic in nature dissociates into K+ and CN−. CN− being ambident nucleophile provides both carbon and nitrogen but attack takes place through carbon as C−C bond is stronger than C−N bond.
CH3Br+KCN→CH3−CN+K−Br
It is a nucleophilic substitution reaction. the reaction takes place by SN2 mechanism.