This is good advice if your phone is actively being hacked in real time when you turn it off. Otherwise all you’re doing is delaying or temporarily interrupting any data collection that’s going on in the background. Any apps that are sophisticated enough to run undetected by a normal user are also going to restart themselves as soon as the phone boots up again.
Also, if you are being targeted by a hacker that is knowledgeable enough to actively get into your device (especially an iPhone) without physical access then you’re better off destroying it and buying a new one, along with doing a full reset of all of your passwords, 2FA setup, and anything else you think you’re relying on for “security”.