The hard part of this puzzle is proving that every configuration stabilizes after $n-1$ seconds.
Numbering the soldiers $1$ to $n$ from west to east, let $E(k)$ be a function which counts the number of East facing soldiers among soldiers $1$ through $k$. Define $W(k)$ similarly. This means $W(k)+E(k)=k$. Then, let
$$
f(k) = W(k) - E(k)
$$
For example, below is a potential soldier line (> means facing east, < west), followed by the resulting graph $f(k)$. Though $f$ is only defined for integers, I've connected the graph of $f$ with straight lines.

Two observations: first, the number of west (east) facing soldiers doesn't change over time. Call these numbers $W$ and $E$. It will always be true that
$$
-E\le f(k)\le W \tag1
$$
Secondly, the function $f(k)$ has a "valley" whenever there are two soldiers facing each other. To be precise, a valley is a point on the graph $(k,f(k))$ where $f(k-1)=f(k+1)=f(k)+1$. The valleys are colored above.
Let's see what happens to the graph $f(k)$ after one second:

Notice that all of the valleys got flipped up to be peaks. Since the passage of time raises valleys, it follows that the height of the lowest valley increases over time. We will use this quantity to prove the desired upper bound.
In light of these observations, at any time $t$ where the configuration is unstable, let $h(t)$ be the height of the lowest valley, so $h(t) = \min_{0\le k\le n} \{f_t(k):(k,f_t(k))$ is a valley$\}$. This means $h(t)$ is undefined if there are no valleys, though the only configuration with no valleys is the final one.
Then $$-E\le h(t)\le W-2.$$
The lower bound follows from (1). To get the upper bound, consider the graph one second later. If there is was a valley at height $h(t)$, then one second later, there will be a peak at height $h(t)+2$. Using (1), we see that $h(t)+2\le W$.
Since there are $n-1$ numbers in the range $\{-E,-E+1,\dots,W-2\}$ (recalling that $E+W=n$), it follows that $h(t)$ can take at most $n-1$ values while the soldiers are unstable. Since $h(t)$ must increase as $t$ increases, after $n-1$ seconds, we can be sure the soldiers are stable.
Finally, we know there are arrangements which do take this maximum time of $n-1$ seconds (for example, when the westmost soldier faces east, and all others west).