How can I tighten a loose rear derailleur onto the derailleur hanger?
Most derailleurs are expected to rotate at the derailleur hanger bolt. This is to simplify rear wheel removal and installation as the derailleur can be moved away from the wheel path by hand. The ability to rotate is not necessarily something that affects shifting quality, but it can be undesirable, especially in certain applications.

As a very recent example, TRP announced a new downhill drivetrain in which the rear derailleur has a separate lever to control rotation around the bolt. To quote a news site:


  Named after Aarons mechanic John Hall, the Hall Lock is, in essence, a lever integrated into the derailleur mount which locks the movement of the B-knuckle around the mounting bolt when closed. Locking the B-knuckle is claimed to reduce chain noise and increase chain retention.