If you draw the state facts as a graph of nodes and edges you get.

Now the query ask for a path from 1 to 9 and the result is a list of the edges from 1 to 9. They are colored green. The edges are f,o,r,t.
Sometimes trying to understand the problem as Prolog is harder than trying to understand the problem in a different manner. As I often note when stuck one option that often helps is to get out a pen and paper.
Before the recursive call, is it going to unify with all possible
value for Y2 ?
No. Prolog unifies the predicates/facts in the order they are written and then backtracks to the next one upon failure. So state(2,o,3) is tried first and succeeds for which the answer is printed. Then because there is a choice point for state(2,_,_) for which state(2,l,4) is then selected. However this eventually fails and thus is not included as a separate answer.
TL;DR
I built the graph using graphviz dot with the file
so_question_07.gv
digraph so_question_07 {
node_01 [label="1", color="green", fontcolor="green"];
node_02 [label="2", color="green", fontcolor="green"];
node_03 [label="3", color="green", fontcolor="green"];
node_04 [label="4"];
node_05 [label="5"];
node_06 [label="6", color="green", fontcolor="green"];
node_07 [label="7"];
node_08 [label="8"];
node_09 [label="9", color="green", fontcolor="green"];
node_10 [label="10"];
node_11 [label="11"];
node_12 [label="12"];
node_13 [label="13"];
color=black;
node_01 -> node_02 [label="f",shape=oval, color="green", fontcolor="green"];
node_02 -> node_03 [label="o",shape=oval, color="green", fontcolor="green"];
node_02 -> node_04 [label="l",shape=oval];
node_03 -> node_05 [label="n",shape=oval];
node_03 -> node_06 [label="r",shape=oval, color="green", fontcolor="green"];
node_04 -> node_07 [label="o",shape=oval];
node_05 -> node_08 [label="d",shape=oval];
node_06 -> node_09 [label="t",shape=oval, color="green", fontcolor="green"];
node_06 -> node_10 [label="m",shape=oval];
node_07 -> node_11 [label="u",shape=oval];
node_08 -> node_12 [label="u",shape=oval];
node_10 -> node_13 [label="e",shape=oval];
}
Here is a simple batch file to covert the gv file to an svg
SET PATH="C:\Program Files (x86)\Graphviz2.38\bin";PATH=%PATH%
dot -Tsvg so_question_07.gv -o so_question_07.svg