You go through Immigration at your first point of entry (i.e. Munich). Your baggage gets checked through to Berlin, and you clear Customs there.
Clearing Customs is very much a non-event in the EU (as long as you are not bringing anything on which you have to pay duty). There is no paperwork, you just go through the appropriate channel, and unless you get picked out for a spot check that's it - you don't have to stop and talk to anyone. Arriving from the USA you go through the green channel (as opposed to the blue EU one).
As regards your connection - I haven't connected in MUC for many years (in fact I have never connected at the present airport at all) so I don't know if 30 minutes is enough. It's got to be a legal connection or you wouldn't have been booked on it.