These are not literal terms, they are figurative. The terms “living” and “dead” are symbolic descriptions regarding the state of a person’s soul.
As such the “sacraments of the dead” are baptism and confession with the rest being the “sacraments of the living.”
The symbolic imagery of the wording is that baptism brings a soul to life and confession brings it back to life after sin. The other sacraments enhance the life of an already “alive” soul.
Some people place “anointing of the sick” in the “sacraments of the dead” category because it does involve the forgiveness of sins.
All in all, the terms are figurative since all sacraments can only be administered to the living persons.