Leg before wicket is the most argued-about dismissal in cricket. A batter is out lbw when the ball hits their body, usually the pad, instead of the bat, and the umpire judges it would otherwise have hit the stumps.
The three questions
Where did it pitch? If the ball pitches outside the line of leg stump, the batter cannot be out lbw.
Where did it hit? The point of impact must be in line with the stumps. The exception is when the batter makes no genuine attempt to play the ball, in which case they can be out even if they are hit outside the line of off stump.
Was it going on to hit the stumps? The umpire has to be satisfied the ball would have gone on to hit them.
Bat first means not out
If the ball touches the bat, or the glove holding the bat, before it hits the pad, the batter cannot be out lbw. That is why so many reviews hinge on the tiniest inside edge.