You buy tickets for wherever you want to go A to B, or in this case Stuttgart Flughafen/Messe (the station at the airport) to Ehrwald. This will include all the trains you need to go on. You do not need to buy separate tickets for each train.
As you are flying in, you cannot predict when you will exit the airport (flight may be late, immigration delays), so just buy tickets at the station when you get there, and accept you won't be getting the cheapest price.
If you miss a train connection due to your incoming train being late, just catch the next train. Reservations are optional on ICE trains, and do not exist on regional trains.
You can look up train times on the DB (German Railways) website. Just look up "Stuttgart Flughafen/Messe" to "Ehrwald". It will take ~5 hours: https://www.bahn.com/en/view/index.shtml
You can also see prices on this website.
Not sure why you are mentioning Garmisch if you want to go to Ehrwald.