Trees are barely a firm category of plant at all. It's basically just tall plants with woody stems. Plants can gain and lose woody stems without too much trouble (relatively speaking, over evolutionary time). So any time a plant species currently growing soft stems can benefit from being really tall, they have a good chance of evolving into "trees".
I’ve seen rather large cactus turn the base of their stems woody and bark clad.