On your first question regarding the possibility of a bracha levatala retroactively being made, this article by dinonline explains
- What if one recited a b’racha for a drink and it suddenly spilled?
If possible, he should drink even a minute amount of the remnants in
order to use the b’racha. Otherwise, he has unfortunately recited a
b’racha levatala and must say the sentence baruch sheim etc.
For the 2nd part of your question regarding spoiled food, the OU writes,
...'If one eats moldy bread or other spoiled foods; one would recite
shehakol. (If one eats his fill of such bread, he would need to
bentch, which is a Biblical obligation – see Bi’ur Halacha 204:1 s.v.
pas she’ifasha.) This is only if the food is a little distasteful; if
it is truly unfit to eat, one would say no bracha on it at all.'
Seemingly, if the food was so spoiled a bracha shouldn't have been made in the first place, it may be a bracha levatala as well.