...And are determined by a number of factors
Including the flight's direction, turbulence, and flight duration. For example, there's “the cardinal direction altitude rule.” This stipulates that commercial airliners traveling Northeast, East, Southeast, and one degree short of South fly at odd altitudes (31,000ft, 33,000ft, etc.), while those traveling all other directions fly at even thousands (32,000, 34,000ft, etc.).
Clear-air turbulence (CAT) affects altitude, as well. Pilots report any turbulence they encounter, and Air Traffic Control (ATC) uses that information to steer other planes above or below it.