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.
Not at all. This is just a particular instance of a general result:
If $A\longrightarrow B$ is a (commutative) $A$-algebra, and $M$ an $A$-module, the $A$-module $B\otimes_AM$ is in a natural way a $B$-module through the scalar multiplication
$$\beta((b\otimes m) \overset{\text{def}}{=}(\beta b)\otimes m.$$
This $B$-module is said to be ‘obtained by extension of scalars’ from the $A$-module $M$.
Best Answer
Notice that $g$ may not be an $B$-module homomorphism.
Instead of trying to show $bg(n)=g(bn)$, you could use your result $p \circ g =id_N$.
Let $b \otimes_A n \in N_B$ be given. Then $p(b \otimes_A n)=bn=(p \circ g)(bn)=p(1 \otimes_A bn)$
Thus $$b \otimes_A n = (b \otimes_A n - 1 \otimes_A bn) + 1 \otimes_A bn $$ where $ (b \otimes_A n - 1 \otimes_A bn) \in \ker(p)$ and $1 \otimes_A bn = g(bn) \in \text{im}(g)$.