An errant cigarette or ember of some sort is highly unlikely yet it appears to be the most likely scenario here. I don’t see any way the Mass Air Flow sensor could have failed and caused the air filter fire and not be completely melted itself. The sensor is after the airflow from the filter and while the engine was still running any flame or smoke would have been drawn into the engine and not back to the air filter housing.
The MAF needs to be replaced, not cleaned.