The following worked for me. This is from https://macreports.com/iphone-keeps-connecting-and-disconnecting-from-mac-fix/
On the Mac, open the terminal,
sudo killall -STOP -c usbd
Or use Activity Monitor to kill the process.
This will restart the USB daemon on Mac. After this, my phone asked for 'Trust' only once.