If you're thinking of using the 27" 2013 iMac as a display for the 2024 MacBook Pro, that's not supported. While the 27" 2013 iMac does support Target Display Mode (using Thunderbolt input), Apple added restrictions on "the other Mac." It has to have been introduced in 2019 and earlier, and be running Catalina or earlier.
Use your iMac as a display with target display mode - Apple Support
You could, perhaps, set up an IP-over-Thunderbolt or Thunderbolt Target Disk Mode connection between the two with the aid of a $50 Apple Thunderbolt 3-to-2 adapter and a $30 Thunderbolt 1/2 cable, but just meeting the Thunderbolt connection requirement isn't going to be enough to make the new Mac support using the old one as a Target Display.