The recursive LCA has base cases. First, if the current node is null, return null. You have reached a leaf's child with no result. Second, if the current node equals p or q, return that node. You found one of the targets, so report it upward.
These base cases drive the entire recursion. When you hit null, that branch has no target. When you hit a target, you stop searching deeper because any descendant of a target is irrelevant. The target itself is the deepest ancestor you can find in that direction. Every recursive call returns either null (nothing found) or a node (target found).