The ideal gas law only holds for gases in equilibrium. Processes which involve successive equilibria steps are called reversible and those which don't are irreversible. The free expansion of a gas is an irreversible process which contains many non equilibrium steps and therefore the ideal gas law is not applicable here. However we can apply it for the final and initial states if you choose to stop the expansion at point in the process. This is because once you stop the expansion, the gas once again falls back into thermodynamic equilibrium after some time.
As a side note I suggest you go read a book called "Atkins physical chemistry" in the first chapter there is a discussion about a surface defined by the implicit function of the ideal gas law. So, this surface may not be defined for all possible values of the state-variables and changing the parameters too violently (like done in free expansion) can drop you out of this surface.
An extra comment is that it is also very very difficult to describe thermodynamic systems which are not in equilibrium. For example, if a system is not in equilibrium then each point inside the system may have different temperatures and it would be difficult to describe without using the language of vector fields and all. For most of high-school learning, we are safe to assume that all points have same temperature, the volume is of container etc.