Visualize kth smallest in a BST step by step. Watch inorder traversal visit nodes in sorted order and stop the moment the count reaches k.
Inorder traversal of a BST visits nodes in sorted (ascending) order. Count nodes as you visit them. The kth one is the answer.
BST inorder traversal yields nodes in ascending order. Kth smallest is simply the kth node visited.
Maintain a counter. Increment it each time you "visit" a node (after returning from left subtree). Stop when count reaches k.
Once the kth node is found, stop recursing. You do not need to visit the rest of the tree.
If kth smallest is queried repeatedly, augment each node with a left-subtree count. Then each query is O(h) instead of O(k).
LeetCode 230. The inorder traversal stack depth is O(h). For a balanced BST this is O(log N); for a skewed tree it is O(N).