The reason it does not work is in this Apple support article:
Use your iMac as a display with target display mode - Apple Support
Obviously the older iMac is compatible with Target Display Mode (TDM), surely being one of the models within the narrow range of iMacs (Late 2009-Mid 2014) that can be monitors for another Mac. The problem lies in the Mac SENDING the video signal to the older Mac.
The last macOS version supported by TDM is OS 10.15 "Catalina." You are running Ventura.
If you need deeper analysis/diagnostics here, please tell us the SUB-MODEL of each iMac including year and screen size.

Also tell us the config that was previously working with TDM. Was it a different source computer, or an older macOS version on the one now running Ventura?
Apple started the deprecation of TDM in Late 2014 and threw the last shovel of dirt in its face in early 2020. It's dead tech to them.