The Ubahn is for local trains, inside the city. It’s the subway, metro, underground. The Sbahn serves the suburbs surrounding the city. You can use either, same ticket. The Sbahn serves Munich airport, which is also served by regional trains and intercity trains.