What are some ways I can avoid getting bad eyesight, since I want to fly attack helicopters?

There are none. Nearsightedness is not caused by anything you do. It is genetic. But all the armed services are now permitting laser vision correction, even for pilots. Before undergoing laser vision correction, check with your recruiter for the specific rules for your branch of service.