Steve Ray has a list of 35 loaded Questions for "Bible Christians" (quotation marks his)(link to the whole list). This is number 24/35. I'm trying to provide the answers in a common format, for easy reference.
24) How were the bishops at Hippo and Carthage able to determine the correct canon of Scripture, in spite of the fact that they believed all the distinctively Catholic doctrines such as the apostolic succession of bishops, the sacrifice of the Mass, Christ’s Real Presence in the Eucharist, baptismal regeneration, etc?
Again, this question is so loaded that even the simple answer, "the Holy Spirit," may not be helpful.
1) Hippo and Carthage actually had two different Old Testament canons.
2) Neither Hippo nor Carthage got the whole canon correct.
3) Athanasius got the whole New Testament canon correct before either Hippo or Carthage. We have evidence for Athanasius, but we don't think he was alone in this regard.
3) The bishops (and others) of Hippo and Carthage did not hold to all the distinctively Roman Catholic doctrines. For example, they did not hold to the immaculate conception or bodily assumption of Mary. They also did not hold to transubstantiation or papal infallibility. The second half of the question is just another one of Steve Ray's half-truths.
4) The half-truth is that the bishop of Hippo/Carthage may have held to baptismal regeneration and to the Real Presence (which is not the same thing as transubstantiation). However, while we have some evidence with respect to Augustine and perhaps a few other of the bishops, we have no extant individual writings for most of them, and the subject matter of their councils doesn't highlight those issues.
5) Getting into the topics of whether the bishops held to "apostolic succession" or the "sacrifices of the Mass" would require a much longer discussion of the anachronism that Steve Ray is employing by inviting the reader to impose modern Roman Catholic categoies onto 4th century Christians.
6) The term "determine" is itself ambiguous. Those councils were able to identify and recognize the correct canon of the New Testament thanks to the leading of the Holy Spirit. That's the same reason that Athanasius was able to do so before those councils and the same reason that we can do so today.