There are 5 National flags that feature a building on them.
Flag of Afghanistan
The building on the Afghanistan flag is featured on the emblem. It's a mosque (also called masjid) and it's a place of worship for Muslims.
Flag of Cambodia
The Cambodian flag has featured a depiction of Angkor Wat (a city of temples built by the Khmer king Suryavarman II in the 12th century) in the center.
Flag of Portugal
The Portuguese flag contains 7 yellow castles with closed gates and 3 towers each placed on the coat of arms.
Flag of San Marino
There are 3 towers in the middle of the San Marino coat of arms that represent the citadels La Cesta, La Montale, and La Guaita.
Flag of Spain
In the first quarter of the Spanish coat of arts (which is included in the national flag), there is a 3-tower castle with blue doors and windows representing the Kingdom of Castile.