Season 1 and 2 were supposed to have 24 episodes (the "normal" amount of episodes for a network show), but for season 1 the finale became a double-length episode.
With respect to season 3: they planned for 22 episodes, but the finale became a double-length episode. Wikipedia does note the remarkable broadcast schedule:
In response to fan complaints about scheduling in the previous
seasons, ABC decided to air the episodes without reruns, albeit in two
separate blocks. In the United States, the first block consisted of
six episodes aired on Wednesdays at 9:00 pm and after a twelve week
break, the season continued with the remaining 16 episodes at 10:00
pm.
With respect to season 4, Wikipedia says:
The season was originally planned to contain 16 episodes; eight were
filmed before the start of the 2007–2008 Writers Guild of America
strike. Following the strike's resolution, it was announced that
only five more episodes would be produced to complete the season;
however, the season finale's script was so long that network
executives approved the production of a 14th episode as part of a
three-hour season finale split over two nights.
Season 5's 17 are due to the two "missing" episodes from season 4 being re-distributed to season 5 and season 6.
With respect to season 6, again quoting Wikipedia:
Beginning with the 2007–2008 television season, the final 48 episodes
would have been aired as three seasons with 16 episodes each, with
Lost concluding in its sixth season. Due to 2007–2008 Writers Guild of
America strike, the fourth season featured 14 episodes, and season 5
had 17 episodes. Season six was planned to have 17 episodes, too.
However, on June 29, 2009 it was announced that the final season would
feature an additional hour, making the number of episodes 18.