Your Agave is genetically programmed to put out a flower stem near the end of is life, normally after about 30 years in its native habitat. After it flowers, it gradually dies as it puts out the adventitious roots and new plants to carry on. Bromeliads also react similarly, gradually dying after flowering, but putting out baby plants before dying.
Nature has many unusual ways to propagate and carry on the species. The way that it does that is usually adapted to its native environment.