Were the Apocryphal writings the primary motivation behind the cannons and councils of the 4th and 5th centuries or were there other motivations? Did the ancient church leaders cite their reasons for making the canons?
I'm not sure which specific councils you're referring to, but for the sake of this answer I'll assume it's the first four ecumenical councils. The Apocryphal writings were not the primary focus of these councils; doctrinal concerns were (the Trinitarian and Christological heresies). Here is a brief summary of these councils:
Concerning the Apocryphal writings, many early Christians considered them to be scripture due to their inclusion in the Septuagint, with the notable exception of Jerome. The lists of books considered "canonical" by many groups today were drawn up very early (fourth century and onward), so there was little dispute (with the exception of the Apocryphal works) when official canons were drawn up in the 16th and 17th centuries.1
So in response to your question, the answer is no, the councils of the 4th and 5th centuries did not primarily deal with Apocryphal writings.