NP is a complexity class that represents the set of all decision problems for which the instances where the answer is "yes" have proofs that can be verified in polynomial time. But hamiltonian path can also be deduced by recursively traversing dfs.
I'm not sure what you mean by "deduced by recursively traversing dfs" but the depth-first search tree is, in general, exponentially large in the size of the graph so any algorithm that potentially involves looking at all of it must take exponential time in the worst case.
Indeed, it's not even obvious that you can solve Hamiltonian path using depth-first search. Consider the graph that is a clique plus one extra vertex, which sends one edge to the clique, say to vertex $x$. If you start your depth-first search at $x$, none of the paths explored by the DFS will be Hamiltonian. Further, if you start at any other vertex in the clique, you might have to explore something like $n!$ paths before you find a path that visits every vertex in the clique, finishing at $x$ and then moves to the extra vertex.