Derive the Units

Retina, 50 48 bytes

 =

+`((.) (.+)\D*)\2(?!\w*])
$1$3
A-2`
](.).
$1

Try it online!

Explanation

 =

Remove all equals signs together with the space in front of them. Who needs those anyway...

+`((.) (.+)\D*)\2(?!\w*])
$1$3

This performs the substitutions of known quantities. It repeatedly matches a quantity definition (the quantity is any character in front of a space and the definition the string after it), as well as some place after the definition where that quantity is used, and insert the definition for the usage. We exclude units from those matches (by ensuring that there is no ] after the match), so that we don't replace [m] with [[kg]] for example. This substitution is repeated until the regex no longer matches (which means that there are no usages of a quantity left, and all lines have been turned into expressions of units).

A-2`

Discard all but the last line.

](.).
$1

Finally, remove extraneous square brackets. Basically, we want to keep the first [ and the last ] but discard all others. Those others always appear with an operator in between, so either as ]*[ or as ]/[. But more importantly, those are the only cases where a ] is followed by two more characters. So we match all ] with two characters after them, and replace that with the second of those three characters to retain the operator.