I’m afraid that there isn’t a way to undo a flag at this moment in time as a normal user. This used to be a thing many years ago. I’m unsure of reasons why it was removed.
Your best bet is to message the moderator group so they’re aware of what you’d like to happen.
If you’re an admin, you can look at changing the post undo action window mins site setting.
I assume you used a flag option that allows you to enter custom text. Then you could edit or reply to the personal message you sent to the moderators. That won’t undo the flag, but it will let them know that you figured it out on your own.
PMs you send are in the “Sent” tab of your inbox /my/messages/sent
Deleting the message does not remove the flag from the review queue. So it’s maybe more helpful to tell the moderators what happened instead of deleting the message.
Actually, deleting the message doesn’t really work. When you do it, the content of the message is replaced by the placeholder as usual, and the message is closed, but it isn’t deleted. So it’s probably even more confusing for the moderators. If they do not notice the lock icon, it will look like you edited the body of your message to the delete text yourself.