Usually, they’ll take a similarity in the life of the saint. In the case of St. Peregrine… he himself, was cured of cancer. Thus, he is the Patron Saint of those who suffer from cancer.
St. Joseph… another good example. He is the Patron Saint of Workers… because he was a humble carpenter.
St. Dominic Savio… Patron Saint of Altar Servers… because he was a young boy, when he died.
St. Therese of Lisieux… Patroness of Missionaries… because she had desired to be a Missionary (but fragile health, prevented it).
St. Francis of Assisi… Patron Saint of Animals… because he so loved all of God’s Creation…
And so on. I think there are several places on the net where you can get “lists” of patron saints. God bless.