Tiled's Terrain system appears to use what are called corner tiles.
That means it uses the following rule to identify what tile to place in each slot:
Identify the type of terrain present at each of the four corners of the tile to be placed
Find a tile in the tileset that has exactly this pattern of four corner types.
These rules are sufficient to handle tilesets like this one (from this guide):

Notice here that each pattern of corners appears exactly once. Reading across the rows, and listing the corner values clockwise from the top-left of the tile:
- empty empty dirt empty
- empty empty dirt dirt
- empty empty empty dirt
- dirt dirt empty dirt
- dirt dirt dirt empty
- empty dirt dirt empty
- dirt dirt dirt dirt
- dirt empty empty dirt
- dirt empty dirt dirt
- empty dirt dirt dirt
- empty dirt empty empty
- dirt dirt empty empty
13 dirt empty empty empty
(You'll notice this forms a binary code we can use to uniquely look up a tile by an integer bitmask - which is how many of these autotiling systems work under the hood)
But that's not the case for the terrain tileset you've authored:

Note that from the perspective of the Tiled program, both these marked tiles have exactly the same corner pattern: grass trees grass grass.
So wherever Tiled sees a tile that needs "grass trees grass grass" it uses one of these, picked arbitrarily (maybe the first or last one it found in its internal ordering), without further deliberation about which tile might fit better.
In this case, you want it to pick the right-hand tile when the tile above it is "trees trees trees grass" and choose the left-hand tile otherwise - but Tiled's terrain system doesn't look further than the current tile's corners to make that selection.
If you want a more global rule to be used in selecting these corners, that will be left up to you.