As @tor-einar-jarnbjo commented, this is usually done on very long running services that don't go directly to their final destination but take a large detour. There are indeed trains that basically go a full loop across Germany within 12 hours.
The main idea behind this is that it might be confusing to name the final destination. The destination named will be one that is about the longest distance the usual traveler will take this train. Using the example in the question, Hamburg-Munich via Berlin which is labeled as going to Erfurt in Hamburg. Erfurt is about the last stop where this is the fastest connection. For further stops, the more direct train is the faster choice.
But, as @strangertokindness noted, this is currently only used in the travel planner app and on the web page. Signs on platforms and in trains usually show the actual route and the final destination. As it is now I think this is rather confusing and not a great idea. On the first glance you might think that you need to change trains, and later you won't find a train matching the description at the platform. It might be better to replace "to Erfurt" by "via Erfurt" to make it clear that this is not a direct train.