I'm assuming that you want to rotate $B_2$ so that its $x$-axis is normal to the $z$-axis of $B_1$. One way to do this is to work in the coordinate frame of $B_2$ by rotating both bodies by $B_2^T$
$$
A_1=B_2^TB_1\\
A_2=B_2^TB_2
$$
so that $A_2$ is the identity matrix $I$. Now rotate $A_2$ about its $z$-axis so that its $y$-axis aligns with the $x$ and $y$ components of the $z$-axis of $B_1$
$$
A_2'=\begin{bmatrix}
c & s & 0 \\
-s & c & 0 \\
0 & 0 & 1 \\
\end{bmatrix}A_2
$$
where $c={v(2)\over|v|}$, $s={v(1) \over|v|}$ and $v=[A_1(1,3)\,\,\, A_1(2,3)]$.
Now the $x$-axis of $B'_2=B_2A'_2$ is normal to the $z$ axis of $B_1$.
If the $z$-axes of $B_1$ and $B_2$ are almost parallel, $|v|$ will be small and you may not want to update $B'_2$ if $|v|$ is less than some multiple of your machine precision.
Let $\mathbf{R}_1$ describe the rotation from global coordinate system to the first local coordinate system, and $\mathbf{R}_2$ describe the rotation from global coordinate system to the second local coordinate system.
Then, $\mathbf{R}_1^{-1}$ describes the rotation from first local coordinate system back to the global coordinate system, and $\mathbf{R}_2^{-1}$ describes the rotation from the second local coordinate system back to the global coordinate system.
When matrix $\mathbf{R}$ is a pure rotation matrix, it is orthonormal, and its inverse is its transpose, $\mathbf{R}^{-1} = \mathbf{R}^T$.
Let's assume right- or post-multiplication between matrices and vectors.
This means that if vector $\vec{v}_g$ in global coordinate system corresponds to vector $\vec{v}_1$ in the first local coordinate system, and to vector $\vec{v}_2$ in the second local coordinate system, then
$$\vec{v}_1 = \mathbf{R}_1 \vec{v}_g \tag{1}\label{EQ1}$$
$$\vec{v}_2 = \mathbf{R}_2 \vec{v}_g \tag{2}\label{EQ2}$$
$$\vec{v}_g = \mathbf{R}_1^{-1} \vec{v}_1 \tag{3}\label{EQ3}$$
$$\vec{v}_g = \mathbf{R}_2^{-1} \vec{v}_2 \tag{4}\label{EQ4}$$
We can substitute $\eqref{EQ4}$ into $\eqref{EQ1}$ to get
$$\vec{v}_1 = \mathbf{R}_1 \mathbf{R}_2^{-1} \vec{v}_2$$
or $\eqref{EQ3}$ into $\eqref{EQ2}$ to get
$$\vec{v}_2 = \mathbf{R}_2 \mathbf{R}_1^{-1} \vec{v}_1$$
This means that to rotate a vector from the first local coordinate system to the second coordinate system, we need to use rotation matrix $\mathbf{R}_{1 \to 2}$,
$$\mathbf{R}_{1 \to 2} = \mathbf{R}_2 \mathbf{R}_1^{-1} \tag{5}\label{EQ5}$$
and from second local coordinate system back to first, $\mathbf{R}_{2 \to 1}$,
$$\mathbf{R}_{2 \to 1} = \mathbf{R}_1 \mathbf{R}_2^{-1} \tag{6}\label{EQ6}$$
Note that due to both matrices being orthonormal,
$$\begin{aligned}
\mathbf{R}_{2 \to 1} &= \mathbf{R}_{1 \to 2}^{-1} \\
\mathbf{R}_{1 \to 2} &= \mathbf{R}_{2 \to 1}^{-1} \\
\end{aligned}$$
There is no need to repeat this procedure for every single case. From the above, we can derive a few rules that will help in this kind of situation immensely.
We consider only column vectors, i.e. $\vec{v} = \left [ \begin{matrix} v_1 \\ v_2 \\ v_3 \end{matrix} \right ]$.
We consider only pure rotation and reflection matrices, i.e. orthonormal matrices, for which $\mathbf{R}^{-1} = \mathbf{R}^{T}$, and is the inverse of rotation by $\mathbf{R}$.
We use right- or post-multiplication of vectors for matrix-vector multiplication. This means that to rotate vector $\vec{v}$ by matrix $\mathbf{R}$, we obtain result, or rotated vector $\vec{r}$, using $\vec{r} = \mathbf{R} \vec{v}$.
We can chain rotations by multiplying the rotation matrices. If the matrices are orthonormal, the result is orthonormal as well. The first rotation is the rightmost matrix in the product, and the last rotation is the leftmost matrix in the product.
To calculate the rotation between two local coordinate systems, we "unwind" the starting coordinate system rotations using inverse rotation matrices in the inverse order, followed by the rotation matrixes in the normal order from global coordinate system to the target local coordinate system.
As an example, assume we have two local coordinate systems whose rotations from the global coordinate system are $\mathbf{R}_1$ and $\mathbf{R}_2$, and we have two further local coordinate systems, $\mathbf{R}_{11}$ and $\mathbf{R}_{12}$ on top of (or relative to) $\mathbf{R}_1$, and two further local coordinate systems $\mathbf{R}_{21}$ and $\mathbf{R}_{22}$ on top of (or relative to) $\mathbf{R}_2$.
In other words, vector $\vec{v}_0$ in the global coordinate system corresponds to:
$$\begin{aligned}
\vec{v}_1 &= \mathbf{R}_1 \vec{v}_0 \\
\vec{v}_2 &= \mathbf{R}_2 \vec{v}_0 \\
\vec{v}_{11} &= \mathbf{R}_{11} \mathbf{R}_1 \vec{v}_0 \\
\vec{v}_{12} &= \mathbf{R}_{12} \mathbf{R}_1 \vec{v}_0 \\
\vec{v}_{21} &= \mathbf{R}_{21} \mathbf{R}_2 \vec{v}_0 \\
\vec{v}_{22} &= \mathbf{R}_{22} \mathbf{R}_2 \vec{v}_0 \\
\end{aligned}$$
then
$$\begin{aligned}
\mathbf{R}_{1 \to 2} &= \mathbf{R}_2 \mathbf{R}_1^{T} \\
\mathbf{R}_{22 \to 2} &= \mathbf{R}_{22}^{T} \\
\mathbf{R}_{21 \to 12} &= \mathbf{R}_{12} \mathbf{R}_{1} \mathbf{R}_2^{T} \mathbf{R}_{21}^{T} \\
\end{aligned}$$
and so on. Simples!
Note that we could write $\mathbf{R}_{22 \to 2} = \mathbf{R}_2 \mathbf{R}_2^{T} \mathbf{R}_{22}^{T}$, but since $\mathbf{R} \mathbf{R}^{T} = \mathbf{R}^{T} \mathbf{R} = \mathbf{I}$ (identity matrix; "no change") for orthonormal matrices, we can omit the identity or "no change" part, and just use $\mathbf{R}_{22 \to 2} = \mathbf{R}_{22}^{T}$.
Best Answer
I think that the paragraph above is where you go wrong. The thing you want is in fact exactly $Q_t = q_t q_{t-1} \cdots q_1$.
I also want to caution you that accumulating these things is likely to give more-and-more-wrong global transformations, diverging from the truth fairly fast. You probably already know this, but just in case, I thought I'd mention it. There's a reason that the device returns local increments rather than a global rotation. :)