Some problems ask for the distance between two nodes repeatedly. Naive DFS for each query takes time. Centroid decomposition can preprocess the tree to answer each query in . Build the decomposition tree. For each centroid, store distances to all nodes in its subtree.
A query for checks their lowest common ancestor in the decomposition tree and combines stored distances. This trades preprocessing time and space for query time. It is useful when you have many queries.
Space complexity is for the data structures used.