It seems after quitting mail there is a brief period of indexing lets hope they show up, be patient. Also note it is only your flags that are missing, the emails should still be in the folders you put them in. The flag does not change it's location, just an easy / quick way to locate them. You can restore old mail it is a little more tricky, however if you restore back in time you will lose any new changes made after that date. This is done in finder.
You can open finder go to GO in the menu bar and press option you will see the hidden Library folder. It is hidden intentionally so you do not accidentally delete or change anything. You can also go to your HOME folder and press COMMAND SHIFT PERIOD and the hidden folders will appear, do it again to make them hidden. You would then choose library go to the mail and Search for your V folders, in one of those you will see a folder for your favorites and each account linked to your apple mail if you have more than one email account linked such as Yahoo Mail, hot mail etc. Once inside the V folder in the you want open Time Machine and you can restore what you are missing. However if you go back to October 2nd and restore you will lose 3rd, 4th, 5th and 6th changes for that folder. It is best only to use this method if you are restoring an extremely important email that is truly lost or you are transferring male to a New Mac.
Remember a missing flag on am email does not mean the email is missing, it means the flag is missing.
If I were you I would try and remember some and reflag them, yes this is time consuming.
Future reference most people only have a limited number of emails flagged, myself it is 19. In the future screenshot them and name them the Folder they are in with the date of the email. Set them aside in a specially named folder. Then you can quickly find your flagged emails location even if it gets unflagged. Then perhaps the email is missing you still have it.
I hope this helps. Your flags should reappear after some indexing is done this takes a while if you got a lot of emails stored.
Be sure to rehide your hidden folders should you be adventurous and look in them.