With expressions such as
$$4\ \mathrm{\frac{m}{s}} \times 2\ \mathrm{kg} = 8\ \mathrm{\frac{m}{s}} \times 1\ \mathrm{kg}$$
We can justify that a $2\ \mathrm{kg}$ mass moving at $4\ \mathrm{m/s}$ has the same momentum as a $1\ \mathrm{kg}$ mass moving at $8\ \mathrm{m/s}$. This might make sense at an intuitive level, but is there a fundamental argument that says units can be manipulated algebraically such that in this case all we've employed is the commutative property?
Or take for instance when we have to do unit conversion and all we do is just cancel stuff according to some proportionalities. We're manipulating units algebraically.
Is this way of doing things blindingly obvious? Or did we have to go out there and find out that it works?
Also, if I have a differential equation such as
$$Lq''+Rq'+\frac{q}{c}=E(t)$$
I usually solve it as if it were an empty math problem and had no units. That is, I only care about the numbers involved. But how do I prove to myself that this way of doing things is right and won't produce contradictions in terms of its units?