The reason why it is true can be explained by hands.
Let $I^2$ be a $2$-square, and $K$ be the union of left, bottom, and right sides of $I^2$.
Then every element of $\pi_2(X,A,x)$ is represented by the map of triples:
$$
\beta: (I^2, \partial I^2, K) \to (X,A,x),
$$
while every element of $\pi_2(X,x)$ is represented by some
$$
\alpha: (I^2, \partial I^2) \to (X,x).
$$
Now if $\beta,\beta'$ are two representatives of elements of $\pi_2(X,A,x)$, then their product $\beta\beta'$ is obtained by "gluing" right side of $\beta$ with left side of $\beta'$, since those sides are mapped into the same point $x$.
Moreover, if $\alpha$ is a representative of some $\pi_2(X,x)$, then one can "attach" $\alpha$ to $\beta$ not only to left or right side, but also to bottom side of $\beta$.
It is convenient to denote such map by $\frac{\beta}{\alpha}$, which means not the division, but indicates a "stack".
Thus
$$
\frac{\beta}{\alpha}(s,t) =
\begin{cases}
\alpha(s, 2t), & t\in[0;1/2], \\
\beta(s, 2t-1), & t\in[1/2,1].
\end{cases}
$$
It remains to note that both $\alpha\beta$ and $\beta\alpha$ are homotopic to $\frac{\beta}{\alpha}$, which means that $\alpha\beta=\beta\alpha$.
In other words, the homotopy between $\alpha\beta$ and $\beta\alpha$ consists of "moving $\alpha$ along $K$ from the left down to the bottom, and then up to the right".
To get a more "conceptual" proof one should use identification $\pi_2(X,x) = \pi_1\Omega(X,x)$ and regard the loop space $\Omega(X,x)$ as an H-space and $\Omega(A,x)$ is its H-subspace.
Recall that a pointed space $(Y,e)$ is called an H-space, whenever there exist a continuous map
$$
\mu:Y \times Y \to Y
$$
such that $\mu(e,e)=e$ and the restrictions
$$
\mu: e \times Y, Y \times e \to Y
$$
are homotopic to the identity map $id_{Y}$ via homotopies fixing $e$.
In the H-space one can define multiplication of loops $\alpha,\beta:(I,\partial I) \to (Y,e)$ by $(\alpha\cdot\beta)(t) = \mu(\alpha(t),\beta(t))$, and on the level of homotopy classes this multiplication coincides with the usual product in $\pi_1(Y,e)$.
In other words $[\alpha\beta]=[\alpha\cdot\beta]$.
Furthermore, a subset $B\subset Y$ is called an H-subspace if $e\in B$, $\mu(B\times B) \subset B$ and the restrictions
$$
\mu:B\times e, e\times B \to B
$$
are also homotopic to $id_{B}$ relatively to $e$.
In this case one can define on $\pi_1(Y,B,e)$ the structure of a group by the following rule: if
$$
\alpha,\beta: (I,0,1) \to (Y,e,B)
$$
two paths started at $e$ and finished in $B$, then their product is given by the same formula as above:
$$
(\alpha\cdot\beta)(t) = \mu(\alpha(t),\beta(t))
$$
One can check that then the natural map:
$$
j: \pi_2(Y,e) \to \pi_1(Y,B,e)
$$
is a homomorphism.
It follows from these formulas that if $\alpha,\alpha':(I,\partial I)\to(Y,e)$ are two loops at $e$ and $\beta,\beta': (I,\partial I, K) \to (Y,B,e)$ are two paths from $e$ into $B$, then it directly follows from the multiplication formulas that
$$
(\alpha\cdot\beta)(\alpha'\cdot\beta') =
(\alpha\alpha')\cdot(\beta\beta').
$$
In fact both maps are given by
$$
\gamma(t) =
\begin{cases}
\mu(\alpha(2t),\beta(2t)), & t\in [0;1/2], \\
\mu(\alpha'(2t-1),\beta'(2t-1)), & t\in [1/2;1].
\end{cases}
$$
Lemma.
The image of $j$ is contained in the center of $\pi_1(Y,B,e)$.
Proof.
Let $\alpha\in\pi_1(Y,y)$ be a loop at $e$ and $\beta\in\pi_1(Y,B,e)$ be path from $e$ into $B$.
Let also $\epsilon:I\to Y$ be a constant map into $e$.
Then
$$
[\alpha\cdot\beta] =
[(\alpha\epsilon)\cdot(\epsilon\beta)] =
[(\epsilon\alpha)\cdot(\beta\epsilon)] =
[(\epsilon\cdot\beta)\cdot(\alpha\epsilon)] =
[\beta\cdot\alpha].
$$
Lemma is proved.
Corollary.
The image of $j:\pi_2(X,x) \to \pi_2(X,A,x)$ is contained in the center of $\pi_2(X,A,x)$.
Proof.
As noted above $Y = \Omega(X,x)$ is an H-space and $B = \Omega(A,x)$ is its H-subspace.
Just replace $\pi_2(X,x)$ with $\pi_1 Y = \pi_1\Omega(X,x)$ and $\pi_2(X,A,x)$ with $\pi_1(Y,B) = \pi_1(\Omega(X,x), \Omega(A,a))$ and apply Lemma above.