How to learn to solve trees, graphs questions for competitive programming
In fact you are adressing an important issue: You were learning concepts, but you are unable to transfer the concepts to real world problems. This is a major issue in many higher education scenarios and e.g. my students always complain, that they do not find the answers to my question in the course material. Of course they don't, otherwise I would not have to ask the question - I assume they are capable of reading and writing ;-).

Now how can you come to that next level of understanding? The answer once again is practice! You have to understand the underlying structure of a problem (e.g. use a divide and conquer approach to decompose the problem) and build a solution based on well-known blocks (like DFS / BFS, sorting, ...). The final step is to adapt the algorithm to your data structures or other specific needs of your problem.

You have to do this over and over again to get practice. Often it helps if you are trying to understand how others did if for some problems, and websites like Codeforces can give you good examples of problems. 

After some practice, you will have gained a good intuition on how to decompose a specific problem. Especially for trees and graphs it is always helpful to draw your data structures and think about how an algorithm would traverse the data structure.