That's not going to work. Your 27" 2013 iMac does not support, and never supported, Mini DisplayPort input.
It does support Thunderbolt Target Display Mode – where you are sending video from another Thunderbolt-equipped Mac over a Thunderbolt connection, and you use a special key combination to tell the 2013 iMac to display the incoming video.
Use your iMac as a display with target display mode - Apple Support
Unfortunately, Apple added some restrictions to Thunderbolt Target Display Mode. The "other Mac" (in this case, the 24" M1 iMac) must have been introduced in 2019 or earlier, and have macOS Catalina or earlier installed. Your 24" M1 iMac is new enough to fail both tests.
So even if you connected the iMacs with a Thunderbolt 3-to-2 adapter ($50), and a Thunderbolt 1/2 cable ($30), you wouldn't be able to use your 27" 2013 iMac in the way you want.