By performing MHD simulations, we investigate the mass loss of intermediate- and low-mass stars from main sequence (MS) to red giant branch (RGB) phases. Alfven waves, which are excited by the surface convections travel outwardly and dissipate by nonlinear processes to accelerate and heat the stellar winds. We dynamically treat these processes in open magnetic field regions from the photospheres to 25 stellar radii. When the stars evolve to slightly blueward positions of the dividing line (Linsky & Haisch), the steady hot corona with temperature, ~ 1MK, suddenly disappears. Instead, many hot (~1MK) and warm (~10^5K) bubbles are formed in cool (T<~2x10^4K) chromospheric winds because of thermal instability; the red giant wind is not a steady stream but structured outflow. As a result, the mass loss rates, \dot{M}, largely vary in time by 3-4 orders or magnitude in the RGB stars. Supported by magnetic pressure, the density of hot bubbles can be kept low to reduce the radiative cooling and to maintain the high temperature long time. Even in the stars redward of the dividing line, hot bubbles intermittently exist, and they can be sources of UV/soft X-ray emissions from hybrid stars. Nearly static regions are formed above the photospheres of the RGB stars, and the stellar winds are effectively accelerated from several stellar radii. Then, the wind velocity is much smaller than the surface escape speed, because it is regulated by the slower escape speed at that location. We finally derive an equation that determines \dot{M} from the energetics of the simulated wave-driven winds in a forward manner. The relation explains \dot{M} from MS to RGB, and it can play a complementary role to the Reimers' formula, which is mainly for more luminous stars.