The rim is positioned by the spokes, but the hub is constrained by the bearings and dropouts. It is a rigid member. The rotor disc is attached to the hub directly.
Disc brakes are not easy to setup and get them right. I'm a hardcore roadie from back before disc brakes were a thing for road. I also have a top shelf mountain enduro bike that has disc brakes. While I work on all of my own road stuff, I avoid working on fork/shock internals and disc brakes. I've worked in several bike shops and I always pay the mechanics to setup my disc brakes. I've learned the hard way of having the annoying things make tons of noise and problems.
There is a Park Tool rotor truing tool that they use to tweak the positioning of the rotor by bending it slightly. It is difficult to tweak them right without making the problem worse. Here is the tool used with a special jig on a truing stand that allows more accurate adjustment without turning the thing into a wavy piece of junk: