I am filling in cracks on a wall. When I use the sander, it takes off existing paint, which then peels off in strips. Is there an easy way to solve this?
If you're using an electric sander then you want to keep that moving all of the time & not linger in any areas. Lingering will heat up the paint & cause it to release. If the paint is peeling off in strips you may also have a poor paint job where Priming before Painting wasn't practiced. But, you won't make that mistake.
You can hand or pole sand with the sandpaper or sanding screen to avoid so much heat & it will also demonstrate how much heat sanding creates. Additionally, you can Wet-Sand with nothing but a Wet household Sponge. This doesn't create heat or even dust. But, definitely remove any loose paint edges as best you can.
If the paint keeps pulling off where you haven't sanded & you have plenty of Joint Compound or Spackle to feather the edge where you finally find sound paint, then rip off as much as possible...This part assumes you have plenty of Primer & Paint to tackle the larger area(s), once with Primer & twice or with 2-coats of Paint.