This happens because if we want (x-A)(x-B)>0, both of the parenthesis have to be positive, or both negative. Thus, must be (x-A>0 and x-B>0) OR (x-A<0 and x-B<0). Therefore, (x>A and x>B) OR (x<A and x<B). So, if A<B, the first parenthesis gives x>B and the second x<A, which, in a diferent form are (B, +oo) and (-oo, A) corespondingly.
Hence, the inequality (x-A)(x-B)<0 gives the opposite answer, which (A, B).