Why km$^2$ and not (km)$^2$? Why don't km$^2$, cm$^3\ldots$ follow the precedence rule of power over product ? One should write (km)$^2$ since it is one million square meters. 
 A: The convention is that units are treated as a single object with their metric prefixes attached. This cuts back on excessive notation, like parentheses. That is, with km we are not treating k and m as separate symbols representing $1000$ and meters respectively. 
A: It has been standardized like this in the International System of Units (SI), see https://www.bipm.org/en/publications/si-brochure/chapter3.html

The grouping formed by a prefix symbol attached to a unit symbol constitutes a new inseparable unit symbol (forming a multiple or submultiple of the unit concerned) that can be raised to a positive or negative power and that can be combined with other unit symbols to form compound unit symbols.

A: $\text{km}$ stands for kilometer, not for "$\text k\times\text m$" where "$\text k$" would denote the constant $1000$.
A: @zahbaz 's answer is correct. It's a convention, and a good one. I think the commenters who say the reason is that "km" is just a single word and not "$1000 \times$ m" are missing an important point. You can indeed and often should think of the metric prefixes for size as factors - and remember that the convention for operator precedence (exponentiation over multiplication) doesn't apply in this context. 
