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:
- Nicaea I (325 CE): Summoned primarily to deal with the Arian heresy, clarifying the relationship between God the Father and God the Son. A creed was developed that became the basis of the later Nicene-Constantinopolitan Creed. The date of Pascha (Easter) was also fixed at this council.
- Constantinople I (381 CE): Arianism and semi-Arianism were still problems for the Church, so the full Nicene-Constantinopolitan Creed was formulated to refute these heresies (and some others such as those of Sabellius, Apollinarus, and Macedonius) and to clarify the relationship of the Holy Spirit in the Trinity.
- Ephesus I (431 CE): This council condemned Nestorianism and Pelagianism. Jesus Christ was defined as the Incarnate Word of God and the Virgin Mary as the Theotokos.
- Chalcedon I (451 CE): This council condemned the heresy of Monophysitism and clarified Jesus Christ as perfect God and perfect man in one person (ὑπόστασις, hypostasis), which is referred to as the Hypostatic Union.
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.