Megacities are absolutely the worst places to hold up security: Too many people and too many places to hide.
That's an opinion, not a fact.
I'd be very surprised if it made any practical difference to a determined and trained terrorist group in practice.
For example, the US president will still be traveling in what is essentially a tank dressed up as a car. They'll all be flying in helicopter with a lot of electronic counter-measures and they won't be any more or less vulnerable to a sniper in a world where a sniper kill can happen at over 3km !
It inconveniences a great many people (Shops here are boarding their windows fearing riots),
And on the other hand it brings a great deal of attention to your megacity in a competitive world where advertising is expensive !
As part of being a host is an opportunity to show off and impress other people, it's also seen as an important benefit that you get to do that.
it costs a big deal of money and preparations (A whole division of police and special security)
Showing off to people who have real power is considered an investment.
If it was held in the middle of e.g. a remote desert, it would require just as much preparation (possibly more), and just as much security. But the security would also require it's own logistical support, which would be even more expensive.
and it curbs fundamental rights (freedom of assembly).
If it actually did curb a fundamental right (e.g. one guaranteed without reservation by a constitution) it could be challenged in court in most of the countries involved.
So I'd suggest it does not actually curb any such right. It's only common sense to e.g. limit the right to assemble a large group of hostile protesters in how close they can approach an area containing the targets of their anger.
As some of the groups who protest (and assemble) hate each other it's also quite a good idea to keep them apart.
So these limitations, when used, are simply common sense policing.
So if the heads of state do not want demonstrations before the door, why don't they meet in a secure five-star bunker in an inaccessible region in a neutral country ?
What's a "neutral country" ? It's a myth. Every country contains groups that are hostile to someone else.
Five star bunkers are expensive to build, maintain and secure. And you have to keep them secure all the time, even when they're not in use (which is most of the time).
Some luxurous mountain fortress in the Swiss Alps? I could even understand that the meet in a city because they have the power to do it, but it does not explain why they don't feel bothered by the severe security disadvantages ?
The security disadvantages are not, IMO, as significant as you think.
Also part of the "showing off" is demonstrating your ability to host an event and mount the required security operation. It is, to some extent, an expression of the host country's competence.
In fact many summits were hosted in more remote regions: G8 in Heiligendamm (2007) and the G7 in castle Elmau (2015). Especially the last one is important because essentially nothing happened during the summit. Only a few demonstrations, no riot, no incidents.
At the G8 Heiligendamm event Greenpeace made a half hearted attempt (by terrorist standards it was half hearted) to break security, so it's not exactly a model for security at a remote location. Would an attempt by a more determined suicide squad of terrorists have been more successful ? We'll never know, luckily.
You mention the G7 Castle Elmau event and I'll quote from the article linked to :
Police spokesman Peter Reichl said that the limited infrastructure made the location challenging for security officials.
“It makes it substantially more difficult,” he told NBC News. “Of course we have a tactical advantage that Castle Elmau is difficult to reach, but we also have big logistical problems.”
So the apparent advantages come with significant (and expensive) downsides.
Remote locations can look secure, but you still have to patrol them and that's no where near as secure as it might sound.
Are there any statements of politicians who give more insight why big cities are preferred as meeting points? Prestige? The infrastructure of a city?
None I know of from politicians (but do we really care what they say ? :-) ), but the example above shows that the security people have major concerns and prefer a relatively built up area with good infrastructure to the remote one without it.
I suspect that if the politicians have a major concern it's access to the media. Again this tends to make a built up area with good logistics preferable.
A cynical person (like me) might believe that when they decide to have a summit in a remote location it's specifically to keep the media (and no-one else) away because they're dealing with some issues they consider even more controversial than usual.
An even more cynical person (almost me) might suggest they want to have a subdued media presence because they expect little will be seen to be agreed at them. Remember that summits are the endpoint to announce agreements and policies that government officials have been working on developing and reaching for months, perhaps years. They typically have a pretty good idea what will be the final result well before the actual event, so while my suggestion is a little cynical, it may not be purely cynical.