Please look at the below images which is the derivation of the relation between the internal energy of an ideal gas and the molar specific heat at constant volume. (Snaps taken from Fundamentals of Physics
Textbook by David Halliday, Jearl Walker, and Robert Resnick)
As the above highlighted part suggests, the equation derived is valid for all processes (given that the gas is an ideal gas), however, the assumptions in the initial phase (or eq.19-39) of the derivation suggest that the process we are studying is at a constant volume and thus, the equation derived should be valid for processes involving constant volume.
Please throw light as to where I am wrong.