As far as I know, a thermoelectric generator has about 5-8% of efficiency. That means it uses 5% of the heat and converts them to electricity. Rest 95% is dissipated through the other side. So I can increase the efficiency by stacking the modules and converting the dissipated heat to electricity again and again. But when I stack the modules, the voltage of the first module starts to decrease whether it's getting the same amount of heat it was getting when it was alone. So why does the voltage decrease after stacking the modules and where is the wasted energy going?
It most likely decreases because your cooling is now less effective. Remember that the important thing for a thermoelectric generator is not the heat but the temperature diffrence. Having a high-temperature hot source is not more important than having a cold cooling sink.
Were there no change in the cold-side temperature of the top generator when stacked, then the generator won't notice that something else has been attached. And then the output would be the same. But that would mean an in-between temperature equal to the cold-side temperature before stacking. The cold-side temperature must then be even lower for the stack - we are thus talking about a completely different scenario for application here, and I doubt that is what you mean.
Also, note that thermoelectric generators are still limited by the Carnot efficiency. Stacking - often called segmentation - done with proper materials that each is optimized for the temperature range at their specific position in the stack, will indeed show increased overall efficiency and is a hot research topic at the moment. The main issue with this is that at every contacting interface there are contact-losses, in the form of resistance against electronic conduction or lowering of the important Seebeck coefficient. Of this reason the joining mechanisms used are very, very important; maybe the most important.