Atiyah-Macdonald Exercise 2.15 I have worked out a solution to exercise 2.15 of Atiyah-Macdonald, which is needed in the solution of 2.3 (see Atiyah-Macdonald 2.3).  However, the solution seems overly complicated, and I am not entirely sure about the argument in part 2. Any corrections and/or improvements would be appreciated.
Question: 
Let $A, B$ be rings (commutative, with $1$). Let $M$ be a module over $A$ and $P$ be a module over $B.$  Let $N$ be a bimodule over $A$ and $B$; that is, $N$ is simultaneously a module over $A$ and over $B$ and the operations are compatible in the sense that $(ax)b=a(xb)$ for $x\in N, a \in A, b \in B.$ 
Then $(M \otimes_A N) \otimes_B P \sim M \otimes_A ( N \otimes_B P).$  Here “$\sim$” denotes isomorphism, where both sides are viewed bimodules over $A$ and $B$.
Attempt at solution:
Step 1: For fixed $p \in P,$ define the map $f_p: M \times N \to  M \otimes_A (N \otimes_B P)$ which takes $(m, n) \mapsto m \otimes_A (n \otimes_B p).$ It’s easy to see that $f_p$ is $A-$multilinear.  Hence it induces a map $f’_p: M \otimes_A N \to M \otimes_A (N \otimes_B P)$ which is a homomorphism of $A-$modules such that $f’_p(m \otimes n) = m \otimes_A (n \otimes_B p)$.
Step 2: Define now $g: (M\otimes_A N) \times P \to M \otimes_A ( N \otimes_B P)$ by $ g(x,y)= f_y’(x).$   We want to show that $g$ is $B-$multilinear. 
We show first that $g$ is $B-$multilinear in the first component.  Note that an element $x\in M\otimes_A B$ is of the form $x = \sum_1^{n} m_i \otimes_A n_i,$ with the $m_i \in M$ and $n_i \in N.$
Hence, for $\lambda \in B,$ we have $\lambda x_0+ x_1= \lambda \sum_1^{n_0} m^0_i \otimes_A n^0_i + \sum_1^{n_1} m^1_i \otimes_A n^1_i = \sum_1^{n_0} m^0_i \otimes_A \lambda n^0_i + \sum_1^{n_1} m^1_i \otimes_A n^1_i.$ 
Hence, we have 
\begin{align}
g(\lambda x_0+x_1, p)&= g( \sum_1^{n_0}(m^0_i \otimes_A \lambda n^0_i) + \sum_1^{n_1}(m^1_i \otimes_A n^1_i) , p) \\
&=\sum_1^{n_0} m^0_i \otimes_A (\lambda n^0_i \otimes_B p) + \sum_1^{n_1} m^1_i \otimes_A (n^1_i \otimes_B p) \\
&=\lambda \sum_1^{n_0} m^0_i \otimes_A (n^0_i \otimes_B p) + \sum_1^{n_1} m^1_i \otimes_A (n^1_i \otimes_B p) \\
&= \lambda g(x_0,p)+ g(x_1,p),
\end{align}
where we have used the fact that $g(\cdot,y)=f’_y(\cdot)$ is $A-$linear.
We can show that $g$ is $B-$linear in the second component by a similar argument. 
Step 3: To show this is an isomorphism, we construct an inverse mapping by the same procedure. 
 A: I apologize if this is old, but I recently worked out this problem, found this question accidently online, and as I had my work written down on paper next to me I decided to share this. 
Let $M$ be a module over $A$, $N$ a module over $B$, and $P$ a bimodule over $A$ and $B$. 
(i) Construct $M\otimes_A P$, this is a module over both $A$ and $B$, and furthermore, it is not hard to show that it is bimodule. 
(ii) Construct $P\otimes_B N$, this is a module over both $A$ and $B$, and furthermore, a bimodule. 
(iii) With the first two constructions, $(M\otimes_A P)\otimes_B N$ and $M\otimes_A (P\otimes_B N)$ will be bimodules over $A$ and $B$. We claim they are isomorphic as bimodules. 
(iv) Fix $n_0\in \mathbb{N}$. Define the map $g_{n_0}: M\oplus P\to M\otimes_A (P\otimes_B N)$ as $g_{n_0}(m,p) = m\otimes (p\otimes n_0)$. It is an easy verification that $g_{n_0}$ bilinear over $A$. Therefore, we get an induced map, $\overline{g_{n_0}}: M\otimes_A P\to M\otimes_A (P\otimes_B N)$ such that $\overline{g_{n_0}}(m\otimes p) = m\otimes (p\otimes n_0)$. This map is linear over $A$, but a little computation will show that it is also linear over $B$ as well. 
(v) Consider the map, $f:(M\otimes_A P)\oplus N \to M\otimes_A (P\otimes_B N)$ defined by $f(\alpha,n) = \overline{g_n}(\alpha)$ where $\alpha \in M\otimes_A P$. This map can be checked to be bilinear over $B$, and satisfies the property that $f(m\otimes p,n) = \overline{g_n}(m\otimes p)$.  Thus, we get the induced map $\overline{f}:(M\otimes_A P)\otimes_B N \to M\otimes_A (P\otimes_B N)$. This map is linear over $B$, but some easy computation will show it is linear over $A$ as well. It satisfies the property that $\overline{f}((m\otimes p)\otimes n) = m\otimes(p\otimes n)$. 
(iv) By repeating steps (iii),(iv), and (v), by interchanging the roles of these modules we get a map $\overline{h}: M\otimes_A (P\otimes_B N)\to (M\otimes_A P)\otimes_B N$ with the property that it is linear over $A$ and $B$, and $h(m\otimes (p\otimes n)) (m\otimes p)\otimes n$. 
Now we have two maps $\overline{f}$ and $\overline{h}$ which are map over bimodules with $\overline{f}\circ \overline{h} = 1$ and $\overline{h}\circ \overline{f} = 1$. This is enough to conclude the isomorphism that we wanted. 
A: Here is the fastest proof I can think of. It doesn't use any elements. It is purely functorial (and therefore also works in more general situations).
Let $A$ be a ring (not assumed to be commutative), $M$ a right $A$-module and $N$ a left $A$-module. Then $M \otimes_A N$ is an abelian group which satisfies the universal property
$$\hom(M \otimes_A N,T) \cong \hom_A(M,\hom(N,T)).$$
Here, we use the obvious right $A$-module structure on $\hom(N,T)$.
More generally, if $N$ is even a $(A,B)$-bimodule, then $M \otimes_A N$ is a right $B$-module satisfying the universal property
$$\hom_B(M \otimes_A N,T) \cong \hom_A(M,\hom_B(N,T)).$$
Now if $P$ is a left $B$-module, it follows
$$\hom((M \otimes_A N) \otimes_B P,-) \cong \hom_B(M \otimes_A N,\hom(P,-)) \cong \hom_A(M,\hom_B(N,\hom(P,-)))$$
$$\cong \hom_A(M,\hom(N \otimes_B P,-)) \cong \hom(M \otimes_A (N \otimes_B P),-).$$
By Yoneda, this means $(M \otimes_A N) \otimes_B P \cong M \otimes_A (N \otimes_B P)$.
