Should I leave it as it is, or leave a comment to this, or flag for moderator attention and explain my mistake?
I do not want to draw attention to the specific question this is why I do not link it here.
There is no way at all to undo a flag. In most cases I would suggest to just do nothing and accept that your flag is going to be declined.
Moderators generally examine the case before acting, so a wrong flag tends to only waste a bit of moderator time, but in most cases does not lead to wrong results.
Personally I'd just keep an eye on the post, and if you notice that your flag lead to a wrong decision, just reflag and explain. This is something I could imagine happening in situations where a quick read leads to a too quick conclusion, but on looking closely the post is not problematic at all. This is pretty rare, in most cases I'd expect nothing to happen due to one mistaken flag.
Flagging for moderators is might not an option. [E.g., one cannot flag as spam and then for moderators (at least not close in time/before the flag is handled); this is different for other flags though, see comments.]
Especially if there is risk of confusion, and if you do not mind doing so, leaving a comment could make sense. I sometimes already saw a comment mentioning inadvertent flagging (mainly for comments where upvote and flag are close together).
But in most cases I think one also could just leave it. It is to be expected there is some rate of error with flags (especially for flags since they are accesible to almost everybody), so it should not be something very unusual for moderators to get an 'incorrect' flag. Also, for some of the flags even certain users see them and can endorse or also contradict them, so handling flagging errors is built in anyway.