When you finish the level, you can earn 1 button per star earned, up to 3. You will be given a chance to double the amount earned by watching the ad, but only when earning those stars initially; after closing the panel you won't be able to double those buttons anymore.

If you return to a level with less than 3 stars and earn additional stars you will be able to double the amount earned for newly earned stars, but not initially earned ones. For example: if you earned 2 stars on the first pass through the level and earned a third on the second pass, when you watch the double reward ad it will only apply o the third star, giving you one extra button.

To sum it up, you can double a reward for any star only the first time that you earn it.