In HCN, the carbon is triple bonded to the nitrogen, and the hydrogen is singly bonded to the carbon. Since nitrogen is more electronegative than carbon, it can draw away electron density from carbon, which favors a deprotonation. If you've learned of alkynes in chemistry, you may know that likewise, with two triply bonded carbons, there is enough electron density so that a carbanion (deprotonated carbon) can more readily form.
For H3CNH2, I usually just recognize that R-NH2 is an amine group. Another weak base of the form R-NH2 is ammonia, where the R group is the hydrogen. If you compare amine groups to ammonia, it may help you remember that given nitrogen's lone pair, it can somewhat readily accept a proton.
So as for the overall difference between the two, I would look to recognize that in HCN, the proton is attached to a carbon attached to a fairly electronegative atom, whereas for H3CNH2, the nitrogen group represents an amine group, which is in general a weak base.