Said another way:
The angle of attack changes the amount of air flowing over the wing. The mass of air flowing over a wing determines lift.
As altitude increases, air density decreases (duh). For the same angle of attack, a higher altitude means less mass of air over the wing while the aircraft's weight remains constant. At some altitude, for any given angle of attack, a stall will occur.