Apple started the deprecation of Target Display Mode six years ago. The LAST iMac that could act as an external monitor for another Mac were the MIF 2014 iMac.
Now Apple have completed the deprecation by removing the ability for 2020 Mac to use an iMac as an external monitor. Even the support article has been archived and is getting no new updates so we have not iDea if TDM can be used form any mac running Big Sur.
Use your iMac as a display with target display mode - Apple Support
So both Macs you mention are now outside of the supported models for TDM.
That leaves some form of network screen sharing. Not the fastest but usually OK fo r business apps.
https://support.apple.com/guide/mac-help/share-the-screen-of-another-mac-mh14066/mac