When we do the work for the indulgence, we ask Our Lord to please give the indulgence to a poor soul in Purgatory. (Some people like to ask Mary to take them to Jesus for him to assign, but you dont have to do it that way.) Or if it’s one we can keep for ourselves and we want to keep it, we tell Our Lord that. I usually give mine away, I maybe keep one a year.
Jesus then assigns the grace from the indulgence as He sees fit. You can ask him to please give it to a specific dead person, for example my friend M just died so maybe I ask Jesus to give the indulgence to M. Jesus will likely honor such requests, but since he has the ultimate say, he could choose to assign the indulgence elsewhere. Also if the person you are trying to give the indulgence to is already in Heaven or Hell instead of Purgatory, Jesus gives the indulgence to another deceased soul. (If the soul is in Heaven then he doesn’t need the prayers, and if he’s in Hell he is beyond help.) You can specify a backup like "if any of my dead ancestors still need help, please help them " or just say "give it to a soul most in need ".
The indulgences operate to reduce the time spent and/or degree of suffering the soul experiences in Purgatory. It helps souls in Purgatory get to heaven faster or more easily. They cannot pray for themselves while in Purgatory so are dependent on prayers of those outside to help them, which can take the form of praying for the person, offering up our daily trials for them, getting indulgences for them, or having Masses said for them. Once they get out they return the favor by praying for those who helped them.