I agree, you're right, but it is a matter of legalities as 2V said since if it were not for that law, any priest could absolve any penitent wherever they are. I'm pretty sure the only place that law is null is on a ship while out to sea.
I think it's the other way around, in terms of emphasis. It's not the law that PREVENTS a priest from absolving, but the intention of the Pope, and then the bishop, to share the power of the keys with the priest. Nor does there have to be any law. At any time, a legitimate Pope could just say, "I grant any Catholic priest jurisdiction/authority to hear Confessions no matter where they're at and whether or not they have faculties to hear Confession." and they would at that moment have the authority. In fact, when a St. Pius X gave permission for Catholics living in Orthodox territories to receive the Sacrament of Confession (and Communion) from Orthodox priests, he was in fact implicitly empowering those Orthodox priests with the necessary jurisdiction. But, again, Canon Law always envisions "normal" times and scenarios, and so it's important to understand the intent of the law, which is to preserve order in the Church and prevent
vagus priests running around creating chaos. When in some kind of necessity, the intent of this law is not violated if some priest were to hear a Confession, even short of "danger of death" scenarios. Let's say a priest was visiting some African country with very few Catholic Churches, or Saudi Arabia, where Catholicism is outlawed, and a Catholic comes up to him and asks to confess, even if the priest was not explicitly granted the jurisdiction, the Church would certainly supply the jurisdiction, even if this individual was not in danger of death, because this action does not violate the intent of the law, but actually corresponds with the Churches highest law, the salvation of souls.