kamran's answer above is a very intuitive and elegant way to look at this. However, I feel it falls a little bit short when looking at the general phenomenon of shear deformation.
First, notice that both pictures you posted, reproduced below for clarity, as well as kamran's drawing, are bodies subjected to simple shear, meaning that there is only one of the 3 possible shear being applied.
So it's natural to ask, ¿are all shear deformations volume-preserving? To answer this we can turn to continuum mechanics and introduce the concept of motion (in the material description) and the deformation gradient.
Let there be a body in a space described by the coordinates $X_1,X_2$ and $X_3$ as shown in the figure below
.
The motion (or deformation) of the body is a function $\mathbf{x}(\mathbf{X},t)$ that describes the position of the particle originally at position $\mathbf(X)$ at time $t$. For example, simple shear is described by
$$
x_1=X_1+kX_3 \qquad x_2=X_2 \qquad x_3=X_3,
$$
which results in the following configuration
To know how much the volume changed, first we look at a line element in the reference configuration, call it $d\mathbf{X}$, and we want to see how it transforms under the motion $\mathbf{x}(\mathbf{X},t)$. The next figure shows the line element $d\mathbf{X}$ and its image on the deformed configuration, $d\mathbf{x}$.
Now we note that
$$
\frac{d\mathbf{x}}{d\mathbf{X}}=Grad(\mathbf{x}) \\
d\mathbf{x}=Grad(\mathbf{x})d\mathbf{X}
$$
But looking at the previous image, $d\mathbf{x}$ is equal to
$$
d\mathbf{x}=\mathbf{x}(\mathbf{X}+d\mathbf{x})-\mathbf{x}(\mathbf{X})
$$
Then, the gradient of the motion, call it $\mathbf{F}$, relates how a line segment transforms under a motion. Now we can apply this to a volume element. Recall that the volume of a parallelepiped is given by the triple scalar product, then in the reference configuration the volume of an infinitesimal volume element is
$$
dV=d\mathbf{X}_1\cdot(d\mathbf{X}_2\times d\mathbf{X}_3)
$$
and, due to the property we just established for the gradient, the volume of the volume element on the deformed configuration is
$$
\begin{aligned}
dv&=d\mathbf{x}_1\cdot(d\mathbf{x}_2\times d\mathbf{x}_3) \\
&=\mathbf{F}d\mathbf{X}_1\cdot(\mathbf{F}d\mathbf{X}_2\times \mathbf{F}d\mathbf{X}_3) \\
&=det\, \mathbf{F}\,\left(d\mathbf{X}_1\cdot(d\mathbf{X}_2\times d\mathbf{X}_3)\right)\\
&=det\,\mathbf{F}\, dV
\end{aligned}
$$
This gives us a way to evaluate the volume change for a body subjected to a given motion.
Going back to our simple shear motion $\mathbf{x}$, it's deformation gradient is given by
$$
\mathbf{F}=\frac{d\mathbf{x}}{d\mathbf{X}}=\left[
\begin{matrix}
1 & 0 & k\\
0 & 1 & 0\\
0 & 0 & 1
\end{matrix}
\right].
$$
The determinant of $\mathbf{F}$ is $det\,\mathbf{F}=1$, meaning a volume element will retain its volume under this transformation (because $dV=1\cdot dv$).
If you had pure (but not simple) shear, i.e. a motion given by, for example,
$$
x_1=X_1+kX_3 \qquad x_2=X_2 \qquad x_3=X_3+kX_1,
$$
then deformation gradient is
$$
\mathbf{F}=\left[
\begin{matrix}
1 & 0 & k\\
0 & 1 & 0\\
k & 0 & 1
\end{matrix}
\right].
$$
Then the determinant of the deformation gradient is $det\,\mathbf{F}=1-k^2$, so pure shear is not a volume-preserving transformation.