I experienced the same problem on a 2019 iMac Retina 27”: Fans always on at full speed, SMC and NVRAM resets didn’t fix it. Booting with D key pressed into diagnostics tool came up with the message indicating I might have a fan problem (ah really?) and error code '''PPF003.'''
Reading your description I realized the connector might be the issue. So '''I just took my flat hand and tapped several times on the back of the iMac'''. Problem solved - no more fan noise! Thanks so much, you saved me from having to send it back to an Apple Store !