This is a way that people apologize for something:
I'm sorry if anyone is offended by my remarks.
But when you apologize this way, it doesn't sound like you're truly sorry. It seems like you still think that you did the right thing.
People use this expression in a lot of situations, from talking to their family members to politicians making a public apology.