A lot of laws (in the States at least) require the capacity to be only what the current student enrollment numbers are at, or at what the enrollment numbers are projected to be when the building is built. This is why you almost always see brand new schools completely full within a few years of being built if they have any sort of normal growth AND why these types of mobile buildings get built. They just don't have any room whatsoever for the student growth. Some schools have started opting for "modular" buildings after the fact to get around this. They're basically permanent buildings but the building is designed so that it can accommodate just about any size room, whether it's offices, classrooms, small gyms, etc.. This allows for the building to be built and ready to go but also not require that it not be an "empty" room so they can kinda sorta have spare classrooms when needed.
money mostly. It's cheaper to do this than it is to build a whole ass new permanent building. Sometimes it's also faster. My highschool (loooong time ago) was planning basically a rolling teardown of the entire campus to rebuild everything like 4X bigger, and to accommodate that they covered a parking lot with these things for the better part of a decade, as they had to wait for summer to do the major "not safe with kids around" construction every year.