With Europe so close to Africa just over the Mediterranean, why didn't countries like Spain, France and Britain colonize it earlier than the 'colonial period'?
Several polities did in fact control northern Africa and southern Europe at once.
Carthage controlled both Spain and north Africa.
Rome defeated Carthage in the Punic wars and would hold Spain, Gaul, Italy, and Africa from coast to coast.
The Umayyads conquered North Africa and Spain (with a bit of modern France)
There were plenty of European Colonies in Africa prior to the more modern "Colonies" to which you are referring. The Graeco-Roman period of dominance provides plenty of examples of this. New cities were often founded as a place for the retired veterans of the army.
http://en.wikipedia.org/wiki/Roman_colonies_in_Berber_Africa
It did start earlier. The Phoenicians (not actually European) founded trading colonies all across the Mediterranean and Northern Africa, including as far on the western shore of Africa as Senegal. The most prominent of their colonies was the city of Carthage, which later expanded into the Iberian Peninsula. Alexander founded Greek colonies wherever he went, most notably Alexandria in Egypt (as well as a number of other Alexandrias. Creativity in naming was clearly not his strong suit). The Romans opted to destroy Carthage rather than attempt to incorporate it into their not-yet-an-empire.
Approaching more modern periods, though, the northern coast of Africa was held by the Muslim Caliphate, as well as the majority of the Iberian Peninsula. Spain, as a country, only came into existence in 1479, less than two decades prior to the start of the age of exploration. Around the same time, the French and English were finally winding down the Hundred Years' War between each other. It basically comes down to opportunity and priority. The Muslims held the southern Mediterranean and Iberia, and the French and British were too busy fighting each other.