How the sun decides the five prayer times
Prayer times follow the sun’s position. Dhuhr begins just after solar noon, when the sun has passed its highest point. Asr is set by shadow length, and Maghrib begins at sunset. Fajr and Isha depend on twilight: the sky’s glow before sunrise and after sunset while the sun is still below the horizon.
Twilight is measured as an angle of the sun below the horizon. Calculation methods choose different angles, roughly between 15° and 19.5°, which is why two apps can differ by several minutes. In northern summer the sun may not sink deep enough at high latitudes, so special rules are used there.
The Hijri calendar is lunar: twelve months of 29 or 30 days make 354 or 355 days, about eleven days shorter than the solar year. That is why Ramadan moves through the seasons, completing the cycle in roughly 33 years.