UnitStep can be used to define piecewise functions regardless of the pieces or their domains. Think of it as a switch, which turns on a function piece within its domain and turns it off otherwise. The definition of UnitStep is
To turn the switch on at some value of x, say x1, we need a term (x-x1) in the argument of UnitStep. To turn it off at another value of x, say x2, we need a term -(x-x2) or (x2-x). If we take the product of these, both terms must be positive for the switch to be on. This is true only if x is between x1 and x2.
For example, suppose you have a piecewise function defined as
Here you have three pieces. The first piece begins at -Infinity and ends at x1, so its term is
The middle piece extends from x1 to x2, so its term is
The third piece begins at x2 and ends at Infinity, so its term is
The complete function is then the sum of these terms.