The two basic types of assignment in Mathematica.
Assignments in Mathematica specify transformation rules for expressions. Every assignment that you make must be associated with a particular Mathematica symbol.
Assignments associated with different symbols.
In the case of an assignment like f[args]=rhs, Mathematica looks at f, then the head of f, then the head of that, and so on, until it finds a symbol with which to associate the assignment.
The left-hand side of the transformation rule is identical to a transformation rule that has already been stored, and any /; conditions on the right-hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.
When you make an assignment like lhs^=rhs, Mathematica will set up transformation rules associated with each distinct symbol that occurs either as an argument of lhs, or as the head of an argument of lhs.
The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:
Mathematica determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.