I am travelling to Munich from Budapest (Deutsche Bahn). Arriving at Munich Hauptbahnhof. Can I travel for free with S Bahn or U Bahn in the city (given that I have the Budapest ticket)?
This depends on the precise destination on the ticket. If it says "+City", then you are allowed to take another train to get to your destination within the city. This option exists for major cities only and the area and conditions vary from city to city. In Munich most of the city is included, shown as "Innenraum" on the local transit maps.
Please see @dunni answer for an additional possibility: If the ticket just mentions Munich and not a specific station (such as Hauptbahnhof / Hbf), you are entitled to continue to any train station (not underground station) in Munich, if the total travel distance is above a certain limit.
If not included, the ticket is valid only to Hauptbahnhof. If necessary, you can book the ticket to any S-Bahn stop as well. U-Bahn, Tram and Buses can not be included on a Deutsche Bahn ticket and require an additional ticket. You can buy this ticket using the Deutsche Bahn mobile app and at ticket machines available throughout the city. Don't forget to stamp the ticket when entering the station (there are no gates that force you to do that).
If the destination on your ticket is written as "München Hauptbahnhof" or "Munich Hauptbahnhof", then your ticket is only valid to that station. However, if the destination on your ticket is written as "München" or "MÜNCHEN", then a mechanism called "Tarifliche Gleichstellung" has effect, which means, that your ticket is valid to all stations within the city, which are mentioned in that document: https://www.bahn.de/p/view/mdb/bahnintern/agb/tarifliche_gleichstellung/mdb_252525_46561_20170307130917_gleichstellungen_20170201.pdf It's only in German, but if you scroll down to "München" you see the list of train stations. Note however that this applies only to DB trains (meaning the S-Bahn in Munich, no U or trams).
As asdfex said, if it says "+City" on the ticket, you can continue to a local destination with it (but only for a single continuation of your main journey -- it's not a day travelcard).
In your case, I would expect that you don't have a city-ticket, because the conditions for the city-ticket include, amongst other things, that both the start and destination stations must be in Germany.
Incidentally, I have in the past obtained free onward local travel (even for international trains) by simply making my booking to a local S-Bahn station rather than a Hauptbahnhof -- in my limited experience, the ticket price ends up the same, but I have no idea how universal this is, and of course it won't work for U-Bahn, bus, or tram.