How can I power off an iPhone if the screen is not working (because it's broken or not detecting touch)? A known way to turn off in iPhone if the screen isn't detecting touch is to let go of the home and power buttons as soon as the screen goes black.
But this sometimes doesn't work, and instead the iPhone restarts.  I wonder why.
Well, the iPhone restarts because pressing the Home and Power buttons simultaneously for a longer period is actually the way to force a restart (on the iPhone 6S and earlier). I think you're simply holding them too long.