According to the first law of thermodynamics, $u=q+w$, where $u$ is changing in internal energy, $q$ is heat liberated and $w$ is the work done in the process.
Now at constant volume, $w=0$, hence $u=q$. Since $q$ is $n\cdot C_v\cdot T$, where $n$ is the amount of substance in mole, $C_v$ is the molar heat capacity at constant volume and $T$ is the temperature change. $u$ comes out to be $n\cdot C_v\cdot T$. However, this expression is valid for all other cases too whether volume is constant or not.
Same is the case with $H=n\cdot C_p\cdot T$. Why so?