You learned DFS explores graphs by going deep first, then backtracking. The visited array prevents infinite loops in cyclic graphs.
DFS finds connected components by counting how many separate traversals you need. On trees, you can carry state down recursive calls to solve path-dependent problems.
Time complexity is for both DFS and BFS. Space complexity depends on recursion depth for DFS and queue size for BFS.