A smoke detector has one job: buy you time. In a house fire, the dangerous thing usually isn't the flames, it's the smoke, and it spreads faster than most people expect. The alarm's whole purpose is to sense that smoke early and give everyone enough warning to get out while there's still a clear path to the door.
Inside the unit is a sensor watching the air for the particles smoke gives off. The moment it detects them, it sounds, and in an interconnected system, it tells every other alarm in the house to sound too, so the warning reaches the bedrooms no matter where the fire starts.
The alarm doesn't put out a fire and it doesn't prevent one. It detects, and it warns. When the sensor is old, the wrong type, or sitting alone with no way to alert the rest of the house, that warning arrives late or not at all, exactly when seconds decide the outcome.