There is a bug with how the game assigns villagers to put out a fire when you have x amount of librarians. I’m not sure what the exact number is but 8 libraries with 2 librarians each was enough to make the bug occur. Instead of grabbing nearby villagers to put out the fire, only librarians are assigned, no matter where they are on the map. Which basically always results in the building burning down.
This behaviour doesn’t occur if another building is set alight from the first building, villagers get assigned as normal to anything that burns from proximity. I’ve seen it on both lightning initiated fires and random fires, so there doesn’t seem to be a difference there. The save I initially saw the bug on was running two mods; but I’ve been able to recreate the issue on an unmodded game by putting enough extra libraries down.