Note that the definition of transitivity says the following: for each $(a,b), (b,c)$ in the relation $R$, we have that $(a,c)$ is an element of the relation.
However, in your case there are no elements $(a,b), (b,c)$, so the relation satisfies the condition to be transitive.
Note that if we would have that $R = \{(1,2), (3,1)\}$, then the relation would not be transitive, since we have that $(3,1), (1,2) \in R$, but $(3,2)$ is not in the relation.
I remember transitivity in the following way: I picture the elements $(a,b)$ of a relation is follows: there is a (directed) arrow from $a$ to $b$. So transitivity means that if there is an arrow from $a$ to $b$ and an arrow from $b$ to $c$, then there is an arrow from $a$ to $c$. The moment you have an arrow from $a$ to $b$ and from $b$ to $c$, but no arrow from $a$ to $c$, the relation is not transitive.