The line in the catechism is in the context that it becomes impossible for the person to be baptised, i.e they die before they're baptised. Since they can never be baptised, if they were not brought to grace and righteous by their intention to be baptised, then they were and will never be availed or helped to grace and righteousness at all. Without BOD, all an intention to get baptised helps you with is getting you baptised, but if you are never baptised then that intention would ultimately amount to nothing. The only way an intention to be baptised could avail you grace and righteousness without you ever being baptised, is if that intention itself could justify you.
This is what St. Ambrose proposed in the 300s AD, and it's the same way that St. Bellarmine and St. Alphonsus interpreted the aforementioned canon of Trent.
No forlorn, it says simply an unforeseen accident, not an accidental death. Grace and righteousness are for the living, not the dead.
If you read further in the catechism, you will find they teach when there is a danger of death that the person is to be baptized immediately.
In Case Of Necessity Adults May Be Baptised At OnceSometimes, however, when there exists a just and necessary cause, as in the case of imminent danger of death, Baptism is not to be deferred, particularly if the person to be baptised is well instructed in the mysteries of faith. This we find to have been done by Philip, and by the Prince of the Apostles, when without any delay, the one baptised the eunuch of Queen Candace; the other, Cornelius, as soon as they expressed a wish to embrace the faith.