Pretty hard to do. Stay healthy, since most who get "legionaire's disease" are already ill with emphysema, heart failure, or other chronic illnesses. Even then, the risk of any one individual getting this disease is extremely (almost unmeasurably) low. Its wasteful to worry about something for which you have so little risk. Better top think about eating well, exercising regularly, wear seatbelts, don't smoke.
Avoid source. Legionnaires' disease is an infection with a legionella bacteria that causes a pneumonia. It is transmitted in a waterborne fashion, often from cooling towers, humidifiers and such. It is not spread person-to-person. It is treated with antibiotics if found. Avoiding the source is the best way to avoid infection. There is no other preventive treatment that I am aware of.