The Thunderbolt 1 and 2 connectors will ALSO do DisplayPort. They will also do USB. It all depends on the cable.
I have used a miniDisplayPort-to-miniDisplayPort cable between an iMac and a Macbook Pro with Thunderbolt 2.
So yes, a newer iMac do not support Target Display Mode. And newer versions of macOS when running on a Mac that used to support Target Display Mode will not let the Mac enter Target Display Mode. But if the iMac supports Target Display Mode, and the operating system supports Target Display Mode, then if you have the right cable, the iMac looks like a DisplayPort monitor.
The Mac (in this case the M1) should not know, nor care that it is an iMac at the other end of the DisplayPort cable, even if the other end is a miniDisplayPort connector.
Unfortunately, my Target Display Mode capable iMac died in 2019, so I am not in a position to test this, especially with an M1 Mac.