Why are the walls stained or bubbling?

The short answer

Efflorescence — mineral salts pushed to the surface by moisture.

The medina sits on a high water table, and the centuries-old walls wick moisture upward through porous materials. When the water evaporates, it leaves white crystalline deposits on plaster and paint. This is the nature of the building, not a sign of neglect.