Take root = [3,4,5,1,2,null,null] and subRoot = [4,1,2].
Start at node 3. Call isSameTree(3, 4). Values differ, so false. Try left child.
At node 4. Call isSameTree(4, 4). Values match. Compare left children: isSameTree(1, 1), match. Compare right children: isSameTree(2, 2), match. Both children of 1 and 2 are null, matching subRoot's nulls. Return true.
You visit up to nodes in root. At each, isSameTree compares up to nodes in subRoot. That's time.
The recursion stack goes as deep as the height of root, so space in the worst case (skewed tree).