If you flagged all of them, it should be fairly simple. Just select all of them, tap flag and select unflag. If you can't select all of them, then you will need to this individually, which would be a monumental task considering there are 2000!
What a nuisance for you! If I were you, I would contact Apple Support. One of my favorite ways to do this is to start an online chat. Click here for a link to Apple Support.
You could fix this with [URL="https://itunes.apple.com/app/p/id1272521597?mt=8&ls=1&at=10l3Vy]AltaMail[/URL] which is free to try for a month. Just use it to fix your flagging problem if you don't want to keep it.
When you view the Inbox, tap on the check/tick button at the top to check all emails.
Swipe left over an email and choose set flag. You could also use the action menu to choose set flag.
The flag may not appear checked in the edit dialog because it is multiple emails, (I have asked them to fix that so we'll see if they do actually listen).
in the edit flag screen tap to turn on the flag, then tap to turn it off. Close the flag dialog and let it process. Leave the app open for a bit and perhaps drag to refresh as it may take a while to process that many emails.