If $A,B,C,D$ are rings (we don't need commutative and noncommutative is instructive to make sure we don't write stuff that is unnatural) and $M$ is a $(A,B)$-bimodule and $N$ is a $(B,C)$-bimodule and $K$ is a $(C,D)$-bimodule, then we have a natural isomorphism of $(A,D)$-bimodules
$M \otimes_B (N \otimes_C K) \cong (M \otimes_B N) \otimes_C K$