I have two coordinate frames, A and B, which are rigidly attached to each other on a body. This body then translates and rotates, such that A starts at A1, and moves to A2, and B starts at B1, and moves to B2. This is shown in the diagram below.

By inspection of the grid, I have calculated the transformation matrix (in 3D homogeneous coordinates) from A1 to B1 to be as follows:
$$ T_{A_1B_1} = \left [\begin{array}{ccc} 0 & 1 & 0 & -2 \\ 1 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right ]$$
Then after the movement, again by inspection of the grid, I have calculated the transformation matrix (in 3D homogeneous coordinates) from A2 to B2 to be as follows:
$$ T_{A_2B_2} = \left [\begin{array}{ccc} 0 & 1 & 0 & 1 \\ 1 & 0 & 0 & 2 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right ]$$
Why are these matrices not the same? Have I calculated them incorrectly? Or is my diagram inconsistent somehow?
Thank you.
Well, if I had to transform $A1$ to $A2$ by a rotation and then a translation I would do it with homogeneous coordinates and in 4 steps (4 matrices).
4) $T_4$: translate right 3 and down 1.
$$T=T_4T_3T_2T_1= \begin{bmatrix} 1&0&3\\ 0&1&-1\\ 0&0&1\\ \end{bmatrix} \begin{bmatrix} 1&0&1\\ 0&1&4\\ 0&0&1\\ \end{bmatrix} \begin{bmatrix} 0&1&0\\ -1&0&0\\ 0&0&1\\ \end{bmatrix} \begin{bmatrix} 1&0&-1\\ 0&1&-4\\ 0&0&1\\ \end{bmatrix}$$
Which gives the full transformation from $A1$ to $A2$
$$ T=\begin{bmatrix} 0&1&0\\ -1&0&4\\ 0&0&1\\ \end{bmatrix}$$
The reason this does not work on $B1$ is because of the rotation. $B1$ is not centered about the origin when $A1$ is. You need to make sure the rotation (or reflection) works for both $A1$ and $B1$ at the same time.