Men (and women) can get yeast infections from loads of different things other than sex. Sweat sitting too long without a shower, soap and laundry detergent, not drying off well enough after a shower, antibiotics etc.
Yeast isn't an sti. Anyone can get them.
Do you mean a yeast infection? Like thrush? This can be from soap or laundry detergent x