That's not quite true. The local councils (Hippo and Rome, I believe) around AD 400 which finalized the NT canon also included the deuterocanonical books. (Some Protestant apologists have an obscure argument which alleges that they didn't define exactly the same canon as Trent, but that's a matter for hair-pulling dispute, IMO. It's beyond dispute that their OT canon was closer to Trent's than not.)
Trent was the first time the canon was defined by an ecumenical council, and thus probably the first time it was defined infallibly.