Flags are values that change depending on certain in-game events. You've got one for nearly each story dialogue, one to know if you've got the dex, one for each story battle,... Depending on your actions, these flags will take different values so that the games knows what you've done or not. That's how story events are triggered at the right time and only once.
Basically, if you set flags correctly you would be able to say to your game "hey, I've beaten the elite four" or "hey, I've got the mega-evolution ability". However, don't mess with them if you don't know what you're doing. You can play with the legendaries flags in order to battle them again but don't modify flags without knowing what it will do or shit will happen
For wondercards, you've got a dedicated thread on how to inject them here.
Your wondercard collection has some slots in which you can store wondercards. Each wondercard has basically 2 states, redeemed and not redeemed : when a WC is not redeemed, the blue delivery girl will apear in every pokemon center so that you can redeem it. Once redeemed, the WC is modified so that it cannot be redeemed again but is still stored in the same slot.
Don't know if I've answered your questions, tell me if there is something in particular you want to know.