Most of such institutes are located on a university campus and have close ties to that university, rotating staff and offering research positions to students as working student as well as for their thesis. It’s also common practice to have a joint program for PhD students.
Having more heterogenous structures of governance and funding within the scientific community of a city/campus instead of a monopoly of a single university is in fact a strength. It would be even better if it were more heterogeneous in Germany, e.g. by having more companies joining right on the campus. BioNTech’s success is a very good example for this.
One fundamental reason for this is that the German law devolves responsibility for education to the states. The federal government is not allowed to influence universities and funding is considered influence. These research institutions are formally not education and thus can receive federal funding. They are, however closely related to universities - using the same facilities, the same personnel, often on-campus or right next to it.
That's how cutting edge research is organized. Surely no one in the US believes sending their kid to Harvard for a bachelor means any of the work done by PhD candidates somehow majorly transcends onto them?
When I was a PhD candidate, I was teaching directly what I was doing research on to bachelor and master students. So did my professor.
The research absolutely impacts teaching to a great extent. We are only humans after all, and I don't have a separate brain for teaching and for research. If you separate your best researchers in research institutes, you're going to seriously limit the flow of knowledge to your bachelor and master students. And those students are your future researchers.