Apples become mealy when the glue holding its cells together gets weak. When this happens, a bite of apple will just disintegrate into individual cells when we chew instead of holding firmly together. The apple tastes dry because most of the water is held inside those cells, which are now harder to break open without that glue to hold them together.
Mealiness mostly happens to old apples that have been kept in storage, or in improper storage, for too long. Buying apples as close as possible to when they were picked is the surest way to avoid getting mealy ones. If you're buying out of season, try tapping the side of the apple: good ones will sound hollow while mealy ones will sound dense and dull.
If you do wind up with a bag of mealy apples, you can still use them in cooking! Cooking helps to break down the cells themselves, releasing the liquid inside. Try using them to make baked apples with oatmeal and brown sugar, a topping for pork chops, or just cook them down into applesauce.
Do you have any tricks for identifying a mealy apple?
Related: Pick Your Own Apples: For Suckers?