How to write units when multiple terms are involved in a derivation? Say I am going to write down the steps of some calculations to get the final value of $s$ from an equation like this:
$$ s = s_0 + \frac12 gt^2. $$
Let us say $s_0 = 20\,\mathrm{m}$, $g = 10\,\mathrm{ms^{-2}}$, and $t = 2\,\mathrm{s}$. What is the right way to write down the units in every step so that all the formula, LHS, and RHS are always consistent in terms of units?
Alternative 1
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= 20\,\mathrm{m} + \frac{1}{2} \cdot 10\,\mathrm{m\,s^{-2}} \cdot (2\,\mathrm{s})^2 \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Alternative 2
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= 20\,\mathrm{m} + \frac{1}{2} \cdot 10\,\mathrm{m\,s^{-2}} \cdot 2^2\,\mathrm{s^2} \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Alternative 2
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= 20\,\mathrm{m} + \left(\frac{1}{2} \cdot 10 \cdot 2^2\right)\,\mathrm{m} \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Alternate 3
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= \left(20 + \frac{1}{2} \cdot 10 \cdot 2^2\right)\,\mathrm{m} \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Are all alternatives correct? Is there any alternative above or another alternative that is widely used in literature?
 A: There's no right way.  But I use and recommend Alternative #1 in the class I teach.  It keeps the value with the unit which makes it easier to go back and find mistakes.
Addendum
Another thing that I try to drill into them with only modest success is to not do "algebra-by-cross-out", but rather to write a complete new line for every step. Again, doing that improves readability and the finding of mistakes.  I absorbed that habit myself after a memorial service for Henry Primakoff at which framed pages of his notebooks were on display ... colorful visual delights in themselves.  It was said that he never skipped a step when doing calculations.  If it was good enough for Primakoff it was good enough for me.  I've been doing it ever since.
I'm pretty sure this disease is spread by well-meaning but misguided high school teachers.  High school teachers listen up:  don't do that.
A: I perfectly agree with garyp: There is no right or wrong way to put the units into the equations. However, in my experience people tend to make mistakes, if they rewrite the equations. That's why I recommend

*

*to convert all units to the standard SI units (no prefixes like nano or kilo),

*do the insertion and calculation of the numbers as a side mark, where we do not include the units, and

*finally just writing the  final result with the SI unit as the solution.

Hence, your calculation would read
$$
s = s_0 + \frac{1}{2}g t ^2 = \fbox{40m}
$$
and the side mark would read
$$
\left(20 + \frac{1}{2} \cdot 10 \cdot 2^2\right)
= 20 + 20 = 40.
$$
