By-products are often formed during chemical reactions where the primary focus is on producing a desired product. For instance, in the manufacturing of pharmaceuticals, certain reactions may yield toxic by-products that need to be identified and managed. Additionally, environmental factors such as temperature, pH, and the presence of other substances can influence the formation of by-products.