As den.thed pointed out, neither of those Macs support Target Display Mode. Target Display Mode went away in Late 2014 when the first 27" 5K Retina iMac came out, and never returned. In addition, no modern Mac supports using ANY iMac (even an old one) as a Target Display.
There's a second-class method you could play with. Both of your Macs are new enough to support AirPlay to Mac. You could set up your 2019 iMac as an AirPlay Receiver and use it as an AirPlay display for your 2021 MBP. AirPlay will not support the full 5K resolution of a 27" 5K Retina iMac, and may be very limited as to what Retina modes (if any) you can use with it. There may be lags and artifacts. But you already have the Macs, so it would not cost you anything to play with the feature.
Continuity features and requirements on Apple devices - Apple Support
Set up your Mac to be an AirPlay Receiver - Apple Support