>How can it be cheaper to fly from Berlin to Munich than taking the car (or the train)?

I can't answer that specific case, but in general it's pretty simple, especially if you're comparing cars and planes: when you drive yourself in a car, you're not only transporting yourself and luggage, you're also taking a 3000-pound hunk of steel. On a plane, it's just you and some bags. You can pack a bunch of people and their crap into an aluminum tube when you give them sardine-sized seats. You get big economies of scale when you do things at larger sizes. And with an airplane, you don't have to take windy, indirect routes and stop at stoplights.

With trains, it's not so clear-cut: trains are generally more efficient than road-going vehicles, because they have lower friction (steel on steel rather than rubber on asphalt), less acceleration/deceleration (no stoplights), and economies of scale (lots of people can fit into a train). One possible problem is the tracks don't go the best route, as they have to conform to both local geography and also history, and tracks are expensive to build (airplanes go directly between airports and the only infrastructure they need is the airports, nothing in between).

Google Maps is ridiculously slow where I am so I'm not going to try finding the driving time between Berlin and Munich, but I'm guessing it's around 3-4 hours? Why a plane might be cheaper (I'm taking your word for it) probably comes down to differences in regulation between airlines and trains in Germany. I agree, it shouldn't be that way; trains should generally be cheaper. Here in the US, trains are generally terrible. Amtrak is actually OK in the northeast corridor, but outside that it mostly sucks: it's very slow, and typically very expensive compared to airfare. The trains frequently don't even have WiFi (outside the NE). They're really comfortable, though, I'll give them that. The coach seats are like 1st-class seats on airlines. But there's probably a bunch of reasons for all this: airlines are largely deregulated here in the US, and there's a ton of competition driving prices down. There's only one Amtrak, with zero competition. Amtrak has to rent space on the tracks from freight companies that own the tracks, and their trains take last place on the tracks (yep, freight gets priority here over passenger rail!). And their trains are generally horribly slow, since we don't have anything resembling high-speed rail, so they're not too attractive to anyone that values their time: no one really wants to spend 3 days (not exaggerating) on a train trip that they can do in 4 hours by airplane.

The competition thing alone is probably one big reason you're seeing that different in Germany. Government-owned agencies just cannot compete against private industry in most cases. When there's no competition and it's nearly impossible to get fired, that leads to an organizational culture which is bloated, ineffective, and overly expensive. I don't know if it's this bad in Germany, but here in the US, if you work at a government agency and need to just buy an office chair, it can take almost a year. Private companies don't work that way because they'd go out of business if they did.