June Hello,
You must buy tickets from the border station of St. Margrethen SG until München Hbf (for your information only, you will first cross Austria with the city of Bregenz before entering Germany at Lindau). Ckeck the timetable to buy tickets for the right train. For example, if the train lives Zurich at 9:33, it leaves St.Margrethen at 10:51.
I suggest to buy these tickets on bahn.de or in the DB Navigator app. If you change your plans, you can cancel the tickets online if they are refundable, it is not possible with the SBB, you must call the Contact Center.
On bahn.de it is also possible to cancel the tickets free of charge during a few hours after purchase if you make an error.
But note that restrictions apply to Supersaver and Saver Tickets, read the conditions carefully. Your seats will be reserved only from St. Margrethen, but I think that they will already be free in Zurich.