After days of smoky air, why is it healthier to stay inside?
If you're in the open air you will be exposed to the full concentration of the pollutants in the air. By being inside, there's a reasonable assumption that the rate of interchange of air between inside a house and outside will be low and that inside there will be a lower concentration of pollutants.

Houses and buildings are not hermetically sealed. The gaps around windows and doors are small which results in low rate of airflow between the outside and inside of the houses and buildings. The less windy the weather the lower the flow rates.

The other way to consider it is when a room has been closed for a lengthy period while someone has been in the room, the air in the room becomes stuffy. This is because the air in the room is not being replaced by fresh air quickly enough to remove stuffy air. To remove to stuffy air the windows and doors need to be left open for a period of time for fresh air to replace the stuffy air.

The same thing happens when the air outside is heavily polluted. The air inside is cleaner and remains cleaner for a longer period if the doors and windows remain shut because the rate of transfer between air inside the building and outside is small.