Windows in a tub-shower area are almost always a problem. No matter what you do, water will find it’s way behind the window frame eventually. You’ll just have to keep at it with regular checkups and re-caulking. No doubt the window was a major factor in your tile problem.
Since you are replacing the drywall behind, you may want to use concrete board instead (also called wonderboard, and other brand names). This is available at most home stores that sell drywall, and is essentially ˝” thick concrete bound by a fiberglass mesh. This is much more durable, impervious to water damage, and is the perfect surface for tile. Even if you plan not to tile, using it will strengthen the wall, improve the moisture-resistance, and allow you to easily go back to tile at a later date. Also, replace the wall insulation if it is moist, smells, or looks moldy.
One more thing about the window. You may want to consider replacing it with one that does not interfere with the tile/enclosure area. In other words, if you now have a window that’s 30” wide by 36” tall, consider a crank-out type that is 60: wide by 12” tall. This may be more challenging to do, especially if the bathroom is on the second floor, but since you are pulling down the old backer board, all the wall studs will be exposed, ant the new design will eliminate the water problem. This is what I have done in the past.
As always, consult your municipality for tips and needed permits. Good luck - TomR