If you're referring to mosques and Islamic flags, it predates Islam when pre-Islamic people (Arabs) worshiped a crescent moon god father of which many statuettes have been found throughout the Middle East. Mecca is where this god being supposedly resided. These pre-Islamists also worshiped a female sun goddess and several 'star' daughters as well as meteorites that would occasionally fall, one of which was incorporated into the Kabba around which modern Muslims worship. This is also probably why they follow a lunar based calendar and carry small swords shaped like crescent moons. Some say one of the names of this moon god was "Allah" but others argue that Allah just means "god". But it's quite likely Mohammed & his followers assimilated pagan traditions and beliefs with his new found faith.