Tree edges are those edges which appear in the final DFS forest. For example in case of connected graph (i.e. resulting dfs forest containg only one tree), if we run DFS over it, edges belonging to the resulting DFS tree are called tree edges.
Let us assume the graph has x number of connected (or strongly connected in case of a directed graph) components. And assume 1st component has K1 tree edges, 2nd component has K2 tree edges and xth component has Kx tree edges.
Such that K1 + K2 + K3 + ........ + Kx = K ( = total)
Or in other way we can imagine like, the final DFS forest has x trees and those trees are having K1 , K2 , K3 , .... Kx edges respectively.
Now we know that a tree having Kx edges contains Kx + 1 nodes. Similarly a tree having K1 edges contains K1 + 1 nodes, etc. and so on.
So, Summation of nodes in each tree = n
$(K_1 + 1) + (K_2 + 1) + (K_3 + 1) + ................ + (K_x + 1) = n \\ \ \ \ \ => (K_1+K_2+K_3+......+K_x) + x = n \\ \ \ \ \ => x = n - K$