While bats have gotten a bad reputation due to the way they look and because of various horror movies, they are very useful animals. A single bat can feed on 8,000 mosquitoes in a single night, so having them around your home can make it a lot more pleasant in your backyard. On the other hand, while it is nice to have bats near your home, you definitely do not want them in your home.
For a bat, your attic can serve as an excellent home since it is usually dark and it will have a small opening with a lot of room to hang for sleeping at night. What will happen, though, is that they will cover the floor with their droppings, possibly spreading disease.
Blocking access to your attic can be difficult, but it is possible. Sometimes, just having the light on in your attic can discourage them from living there since they are nocturnal, but it is not always enough. If you find their entry point, you could install a one way excursion device which will let them exit but not get back in.