Could you please explain in detail how bubbles function in the context of financial markets? I'm particularly interested in understanding the mechanisms that lead to the formation of these bubbles, as well as the factors that trigger their burst. Additionally, could you also discuss the potential impact of bubbles on investors and the overall economy? It would be helpful if you could provide examples or case studies to illustrate your points. Thank you for your assistance in clarifying this complex topic.