I believe your ring $R$ is supposed to be commutative, otherwise see here for example https://mathoverflow.net/questions/21899/definition-of-an-algebra-over-a-noncommutative-ring.
The answer is hidden in the what are the actions of $R$ on the two algebras. An $R$-algebra is a ring with an action of $R$ (which is a left and right action since $R$ is commutative), and the maps $f \colon R \to S$ and $f \colon R \to T$ give you the actions.
They are $R \times S \to S \colon (r,s) \mapsto r \ast s := f(r) s$, with the multiplication of $S$, and similarly for $T$.
Therefore, in the tensor product $S \otimes_{R} T$, the left action on $T$ and the right action on $S$ are needed in order to define the tensor product. Moreover, the left action on $S$ and the right action on $T$ will give the additional structure of $R$-algebra, and these are the ones we use.
To come back to your question, the equality is proved by
$f(r) \otimes 1_T = (f(r) \cdot 1_{S}) \otimes 1_T = (r \ast 1_S) \otimes 1_T = 1_S \otimes (1_T \ast r) = 1_S \otimes (1_T \cdot g(r)) = 1_S \otimes g(r)$, where the essential step is the use of the relation $r a \otimes b = a \otimes br$.