A gland usually swells because it is trapping undesirred particles from the body, for example, if you have an infection, the gland that is in the area of the infection will grab the bad bugs so to speak to clear the infection.
In so doing the gland will swell. If you have a toothache you can get a swollen gland. If you have a sore throat
you can get a swollen gland. Head infections too.