First part of your question:
The solution comes from solving the SDE specified in the paper and then using the moment generating function of a normal random variable.
Formally, let us define the SDE specified in the paper:
$$dS_u = \sigma dW_u,$$
with initial value $S_t = s$. To get the solution to the above SDE, we can integrate from $t$ to $T$ on both sides:
\begin{align*}
\int_{t}^T dS_u &= \int_t^T\sigma dW_u.\\
&\Updownarrow\\
S_T - S_t &= \sigma (W_T - W_t) \\
&\Updownarrow\\
S_T &= S_t + \sigma (W_T - W_t)
\end{align*}
Since Brownian increments are normally distributed with $W_T - W_t \sim N(0, T-t)$ and we further have that $S_t = s$, we get the following distribution for $S_T \sim N(s, \sigma^2 (T-t))$.
Now, reformulating the expectation in your second formula gives us:
$$\mathbb{E}_t\left[-e^{-\gamma(x + qS_T)}\right] = -e^{-\gamma x}\mathbb{E}_t\left[e^{-\gamma q S_T}\right],$$
where $x$ is the initial wealth in dollars and is just a known constant.
Remember that the moment generating function of a Normal random variable with distribution $X \sim N(\mu, \sigma^2)$ is given by (see here for formula):
$$\mathbb{E}\left[e^{tX}\right] = e^{t\mu}e^{\frac{1}{2}\sigma^2t^2}. $$
Using this formula, we get the desired result:
$$-e^{-\gamma x}\mathbb{E}_t\left[e^{-\gamma q S_T}\right] = -\exp(-\gamma x)\exp(-\gamma qs) \exp\left(\frac{\gamma^2 q^2 \sigma^2 (T-t)}{2}\right)$$
Second part of your question:
We need to observe that the authors now use a driftless GBM as SDE:
$$\frac{dS_u}{S_u} = \sigma dW_u,$$
with initial value $S_t = s$. This has the solution:
$$S_T = S_t e^{-\frac{\sigma^2}{2}(T-t) + \sigma (W_T - W_t)}.$$
Calculating first and second moment:
Let us redefine $S_T$ as
$$S_T \overset{d}{=} S_t e^{-\frac{\sigma^2}{2}(T-t) + \sqrt{T-t}\cdot x},$$
where $x$ is normal distributed with $x \sim N(0, \sigma^2)$ and furthermore its squared counterpart is given by:
$$S_T^2\overset{d}{=} S_t^2 e^{-\sigma^2(T-t) + 2\sqrt{T-t}\cdot x}.$$
Calculating the moments follows from the moment generating function defined above and we conclude that:
\begin{align}
\mathbb{E}_t\left[S_T\right] &= \mathbb{E}_t\left[S_t e^{-\frac{\sigma^2}{2}(T-t) + \sqrt{T-t}\cdot x}\right] \\
&= S_t e^{-\frac{\sigma^2}{2}(T-t)} \mathbb{E}_t\left[e^{\sqrt{T-t}x} \right]\\
&= S_t e^{-\frac{\sigma^2}{2}(T-t)}e^{\frac{\sigma^2}{2}(T-t)}\\
&= S_t
\end{align}
\begin{align}
\mathbb{E}_t\left[S_T^2\right] &=\mathbb{E}_t\left[ S_t^2 e^{-\sigma^2(T-t) + 2\sqrt{T-t}\cdot x}\right]\\
&= S_t^2 e^{-\sigma^2(T-t)} \mathbb{E}_t\left[e^{2\sqrt{T-t}x}\right]\\
&= S_t^2 e^{-\sigma^2(T-t)}e^{2\sigma^2(T-t)}\\
&= S_t^2 e^{\sigma^2(T-t)},
\end{align}
and remember that $S_t = s$.
Now, rewriting your third equation and inserting the above moments, we get the answer as depicted in your fourth equation:
\begin{align}
\mathbb{E}_t\left[x + qS_T - \frac{\gamma}{2} \left(qS_t - qs\right)^2\right] &= \mathbb{E}_t\left[x + qS_T - \frac{\gamma}{2} q^2(S_t - s)^2\right]\\
&= x + q \mathbb{E}_t\left[S_T\right] - \frac{\gamma}{2} q^2 \mathbb{E}_t\left[(S_T-s)^2\right]\\
&= x + qs - \frac{\gamma q^2}{2} \mathbb{E}_t\left[S_T^2 + s^2 - 2 S_T\cdot s\right]\\
&= x + qs - \frac{\gamma q^2}{2} \left(\mathbb{E}_t\left[S_T^2\right] + s^2 - 2s^2\right)\\
&= x + qs - \frac{\gamma q^2}{2} \left(s^2 e^{\sigma^2 (T-t)} - s^2\right)\\
&= x + qs - \frac{\gamma q^2 s^2}{2} \left(e^{\sigma^2 (T-t)} - 1\right)\\
\end{align}
I hope this provides a bit of help.