Dimensions changed cube (prism) is still a cube when UV unwrapped
UV unwrap is here applied on an uniformly scaled object. 

If the scale is non uniform (for instance X=1, Y=1, Z=2), the unwrap will be applied on a non scaled version of the mesh.

This can be seen if you stretch the information panel a bit (on top of this picture) :



So as a solution :


Use Ctrl + A 
And select scale
Then unwrap again




Concerning the reason (as you asked in the comments of your question), I presume this is due to the fact UVs are part of the mesh data and scale is relative to the object data. So this allow to have uniform UV for several objects sharing the same mesh data, but having different scales.