I was in conversation with an acquaintance. They start talking about their kid, so I said something intended as a compliment to their child, but that led to them telling me about their kid's congenital disorder, which I didn't expect to hear at all. It wasn't my intention to pry into something so private and understandably painful that they probably didn't feel comfortable letting other people know.
This is a post hoc question, as looking back now I think I should have apologized more properly. I think I said something to the effect of 「余計なことを聞いちゃってすみません！」 But retrospectively I am not sure 「聞いてしまう」 was a good word, because I don't think I actually asked anything. Because of an honest mistake intended as a compliment, the flow of the conversation sort of compelled them to give me an explanation of a private situation which I worry might have made them feel unnecessarily uncomfortable, sad, or at the very least awkward. Also I don't think I should've described something so close to their heart as 「余計なこと」.
I would have been hesitant to use 変なこと too, because wouldn't that feel like I was saying their kid or their kid's condition was 変? I think neither of those is anything close to what I would like to express.
Maybe something like this?
In English, it's common in such situations to say things like "Oh I'm sorry! I didn't know!" "I am so sorry! I didn't mean to pry."
I would like to know the best ways to apologize in this situation, in different registers: informal, formal, and business.