A square object is defined by points $(2,2)$, $(2,4)$, and $(4,2)$. The square is scaled up by factor $3$, and rotated clockwise $45$ degrees about its centre. Demonstrate the composite matrix of the operations with detailed calculations.

In the answer, there is an additional translation matrix provided and I am unsure where it was derived from.
I assume it would be to centre the object? Any confirmation or valid reason is appreciated.
Thank you.
As I commented above, you might work with $2\times 2$ matrices with a different approach. Since the center of the square in $(3,3)$, you may change the coordinate so that the square has the center at $(0,0)$.
Define $T \begin{pmatrix} x\\ y \end{pmatrix}= \begin{pmatrix} x-3\\ y-3 \end{pmatrix}$
and $S \begin{pmatrix} x\\ y \end{pmatrix}= \begin{pmatrix} 3x\\ 3x \end{pmatrix}$
Finally the rotation matrix:
$R \begin{pmatrix} x\\ y \end{pmatrix}= \begin{pmatrix} x\cos\frac{\pi}{4}-y\sin\frac{\pi}{4}\\ x\sin\frac{\pi}{4}+y\cos\frac{\pi}{4} \end{pmatrix}$
The transformation $M$ you are looking for is $$M=T^{-1}RST.$$
More precisely
$$M \begin{pmatrix} x\\ y \end{pmatrix}=T^{-1}RS \begin{pmatrix} x-3\\ y-3 \end{pmatrix}= \cdots=T^{-1} \begin{pmatrix} (3x-9)\cos\frac{\pi}{4}-(3y-9)\sin\frac{\pi}{4}\\ (3x-9)\sin\frac{\pi}{4}+(3y-9)\cos\frac{\pi}{4}\end{pmatrix}= \begin{pmatrix} (3x-9)\cos\frac{\pi}{4}-(3y-9)\sin\frac{\pi}{4}+3\\ (3x-9)\sin\frac{\pi}{4}+(3y-9)\cos\frac{\pi}{4}+3\end{pmatrix}$$