Dynamics of phase transitions in YVO3 investigated via inelastic neutron scattering and first-principles calculations