A few more corrections (sorry, I should have finished reading before commenting):
Flatpaks can use a Gnome or KDE platform, but they don't have to. If an app wants to include all of it's dependencies, rather than say it needs one of those platforms installed, it can do that. Platforms are also provided via Flatpak, not by the distros themselves.
However, I don't think that a flatpak can depend on more than one Platform at a time, so if your app needs Java *and* Gnome, you'll have to include one or the other in your app package.
In any case, the attack surface for both Flatpak and Snap is limited by the runtime confinement, which largely negates the added risk that bundling dependencies cause.