[Just a couple of milestones and changes listed here, feel free to expand]
in the first years, during construction, ISS was occupied by three people, traveling with the Shuttle.
after the Columbia disaster, the crew was reduced to two in Soyuz.
when the Shuttle was back in operation, a third crew member launching from the US was added again. Although the Shuttle could have shuttled more than one astronaut forth and back, and the ISS was large enough to support more people, this wasn't possible: there was only one Soyuz capsule with three seats docked that was the emergency return vehicle for the whole crew.
in 2008 and 2009 things got a bit "messy" due to the frequent Shuttle launches to finalize assembly of ISS and crew numbers changed a lot.
after retirement of the Shuttle, only Soyuz with a crew of 3 was operational and the ISS crew stayed stable at 6 with short periods of 3 in between launches.
in 2017 Russia decided to reduce the number of cosmonauts to two to save money. This lead to two launches with a crew of 2, before the vacancy was filled with NASA astronauts.
in 2020 Crew Dragon became operational, enabling to send 4 people in one craft and the ISS crew increased to 7, with up to 11 during the planned 1-week hand-over periods.
So, the crew on the ISS was mainly driven by available space during the first years and available launchers during the rest of the time with short periods of budget reduction. It was once stated that 3 is the base crew needed to operate the station, leaving not much time for scientific work, while the fourth and further person can mostly focus on actual science.
The times with more than 7 people on board the station are always very short, usually up to two weeks. Currently "expeditions" can't be defined by a common crew any more. E.g. in expedition 65 the first people left 5 months before the last one arrived.