Following the conquest of North Africa by Muslim Arabs in the 7th century CE, Islam spread throughout West Africa via merchants, traders, scholars, and missionaries, that is largely through peaceful means whereby African rulers either liked the religion or converted to it themselves.
Islam (like all other religions do in their respective regions) integrated itself within North African cultures via trade and commerce that North Africa was so heavily affiliated with.