Rational matrix and operator functions with prescribed singularities