Target display mode is a feature that was available only with certain older iMac models.
The feature was deprecated by Apple several years ago and is no longer supported in either hardware or software.
Please see: Use your iMac as a display with target display mode - Apple Support
Only the following older iMac models could be used as an external display when plugged into another older Mac model:
- iMac models introduced in 2011, 2012, 2013, and mid 2014 using Thunderbolt or Thunderbolt 2 cable.
- 24-inch and 27-inch iMac models introduced in 2009 and 2010 using Mini DisplayPort cable.
Per the link above re TDM:
- The intended target iMac must be running macOS 10.13 High Sierra or earlier; it does not work with macOS 10.14 Mojave or later, or with Boot Camp and Windows.
- Retina display iMacs won’t work as target displays.
- In all cases the source Mac that you're connecting FROM must have been introduced in 2019 or earlier and have macOS 10.15 Catalina or earlier installed.
So, given these caveats, I'm surprised that your 2021 MacBook Pro even connects with one of your iMacs at all.