To be a glutton for punishment is an idiom that means to willfully take on difficult or disagreeable tasks that may be very uncomfortable. The word "glutton" tends to mean overeating, and originates in Latin with the related words gluttus which means greedy, and gluttires which is translated as to swallow. The word gula may be similarly related and translates as throat.
In most cases, being the term "glutton" in this phrase is different than being gluttonous. Gluttony in general is one of the deadly sins, since people who eat too much, greedily and often are most interested in themselves (according to those who track sins in this manner). Being a glutton for punishment usually means that the person welcomes difficulties and may be accepting requests or tolerating difficult circumstances to please others. It is more other-motivated than self-motivated.
The phrase is frequently said wryly and jokingly. Most people have a variety of reasons for persevering despite obstacles, or for inviting that annoying brother-in-law to a golfing afternoon or a critical mom on the family vacation. It isn’t so much that most people actually crave punishment or hard times, but many people find that it’s occasionally necessary to undergo difficult things to make life better for themselves or others. While the individual may have to listen to the annoying brother-in-law talk endlessly about his job for a few hours, it may make his sister feel more happy. Similarly, taking another job on at work when an employee is already pressed for time might make his boss happy, which could benefit him in the long run.
Interestingly, some people do seem to become almost gluttonous in their desire to be perceived as martyrs. A true glutton for punishment may want to constantly seem overburdened so they will evoke the pity of others, and they may take on far too much. People also might overextend themselves because they have difficulty saying no to people they respect or love. In this case, learning to set limits so as not to choose misery for the sake of pleasing others is probably a very good idea.
On the other hand, some people actually feel most alive and thrilled when they are overextended or at least working very hard most of the time. In which case, such a person is not truly living up to the sense of the idiom. If working hard is enjoyable, hard work can scarcely be considered a punishment.