Just to help, the Bermuda 2 agreement does not stipulate countries, only cities.
Both these operations from London to Germany were actually long-standing, Pan Am and TWA continuing to through-route 747s to Frankfurt; back in propeller aircraft days they both had a much larger representation on this route, with multiple daily flights each. In 1980 Pan Am also used a 727 (one of the Berlin fleet) from Heathrow to Hamburg, which continued to Berlin, and connected with the inbound transatlantic flights; I can recall seeing them coming over Central London at breakfast time. The Berlin "corridor" flights from West Germany collected a subsidy from the authorities, so it made financial sense for them to stop in West Germany and thus collect this - BEA/BA used to do the same. There was no real intention to handle local passengers, but it used to skim a proportion of the morning traffic from BA and Lufthansa. United did the same with 727s for a couple of years when they took over Pan Am's flights, whereas American never did follow through TWA's rights.
Over the years things switched around. By 1988 the ill-fated PA103 had used a 727 from Frankfurt to London, changing gauge there onto the 747 which was destroyed at Lockerbie.
East Berlin was sort of in the DDR (the Allies refused to accept that though, legally speaking)
This led to WHBM being thrown off an East Berlin tram in the 1980s by the Stasi on a route which crossed the quite unmarked border from Berlin City into the DDR. I had thought I'd be quite OK and unchecked going down to the end of the line and back, but they boarded at the first stop after the invisible line, and came straight for me. All very politely done, and the two of them just put me on the next one back into the city. I swear I nearly got a salute from them as the return tram set off. What a fascinating place Berlin, both sides, was for transport in those times.