Why are you trying to connect them?
Are you trying to use one as a display for the other?
Target display mode is a feature that was available only with certain older iMac models.
It is no longer a function supported by Apple in either hardware or software.
Only the following older iMac models can 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.
- 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.
click> https://support.apple.com/en-us/HT204592