Left and right factorizations of rational matrix functions