Because flying is not what makes a bird a bird. Ostriches, kiwi, and emus are all birds but they can't fly. Bees, bats, flys, and beetles can fly but are not birds.
Bats are mammals because, like all mammals, they make milk for their young. Bats are not birds because they don't have feathers, they don't lay eggs, and are built very differently from birds. A bat wing doesn't look anything like a bird wing, for instance.