How to prove that a function is affine?

A function is affine iff $T(\lambda x + (1-\lambda) y) = \lambda T(x) + (1-\lambda) T(y)$ for all $x,y$ and $\lambda \in \mathbb{R}$.

It is straightforward to show that the above definition is the same as the one in the question.

You can use this to answer your question by checking that $T(\lambda (x_1,y_1,z_1) + (1-\lambda)(x_2,y_2,z_2)) = \lambda T((x_1,y_1,z_1)) + (1-\lambda)T((x_2,y_2,z_2))$ for any scalar $\lambda$.

Also, note that if $T$ is affine and we let $L(x) = T(x)-T(0)$, then $L(\lambda x) = T(\lambda x) - T(0) = T (\lambda x + (1-\lambda) 0) - T(0) =\lambda T(x)+(1-\lambda) T(0) - T(0) = \lambda L(x)$, and $L(x+y) = 2 L({1 \over 2} (x+y))= 2 T({1 \over 2} (x+y)) - 2T(0)= 2( {1 \over 2}(T(x)+T(y)))-2 T(0) = L(x)+L(y)$. Hence $L$ is linear, and we can write $T(x) = T(0)+L(x)$.

It is easy to check that if $L$ is linear and $c$ is a constant vector, then $T(x) = L(x)+ c$ is affine.

So we see that $T$ is affine iff it can be written as a constant plus a linear function.

In your case, we see that we can write $T((x,y,z)) = A (x,y,z)^T + b$ for some matrix $A$ and some vector $b$.