Some plants do so based upon how much light they get. Other plants flower based on conditions in the growing medium and environment (nutrients, temperature, moisture, weather conditions etc.).
Some do so purely based on their genetics and time alive.
This is the simplest way I can answer this without getting technical or into specific plants.
Edit: A couple typos
Latest Answers