In theory it is possible to catch an infection in the gym, for example from bacteria such as staphylococcus aureus (staph.) lurking on gym equipment or yoga mats. Fortunately, the risk of acquiring such an infection is low.
However, if you suffer with recurrent boils, it is worth re-thinking your gym routine. That includes making sure you shower immediately after exercising, washing all your gym clothes after each use (bacteria thrive in warm, moist environments), and wiping any gym equipment as well as the inside of your gym bag with anti-bacterial wipes.
Another type of infection you might acquire at the gym is a fungal infection. This might show itself as an itchy rash in your groins (jock itch), between your toes (athlete’s foot) or in other skin areas. Measures to help avoiding this are wearing loose, breathable clothing, taking your trainers out of the gym bag as soon as possible to let them dry out and making sure to dry skin-on-skin areas such as the groins and in between toes extra carefully after each shower.
Enjoy your work-out!