Fastest way: open Control Center (swipe down from the top-right corner on Face ID iPhones, or up from the bottom on older ones) and tap the flashlight icon so it goes dark. On the Lock Screen you can also press and hold the flashlight button at the bottom-left, then swipe it off. If it keeps switching on in your pocket, that's the Lock Screen button being pressed against your leg, a case with a slightly raised front edge stops it. A quick restart also clears a stuck flashlight if the toggle won't respond.
Control Center is the reliable spot, the same icon that turns it on turns it off. People forget the flashlight lives there as well as on the Lock Screen.
Pocket activation is the Lock Screen buttons getting squeezed. A case with a raised front bezel keeps the screen off your leg, which is what triggers it.