I've read that there are multiple batteries inside a smartphone, so even when you turn it off it can still communicate with other devices. So my question is, could a smartphone get hacked even when off? For example, if your smartphone is off and near an infected router, or some other device with malware, could it get hacked?
I believe it won't cause it's "turned off". But I think the case is different when your phone is "turned off and charging". You notice when charging that some stuff appears in your screen? Those are programs that run when the device detects that it has plugged into a charger.
But alas, I do not have the knowledge to exactly know the actual things happening underneath all those fancy displays when your phone is charging so I can't really tell if those programs could actually wake and take control of the wireless controller within your Smartphone. But even so, it's not possible to magically hack your phone with this fact because those programs would never wake the wireless controller even if they are capable of doing it.
The only case they will wake it up is if they have been infected/turned rogue by a hacker in the first place that was already able to get high-level access to your phone while it is turned on.
So to TL;DR answer your question. No, it is not possible to magically hack your phone when it is turned off and even if it is "turned off and charging".
Side note: I do not know if it is possible to turn on a smartphone while it is connected through USB but actually hacking your phone involves it being turned on first. Only then can the hacking actually take place.