We regularly install towel bars and toilet paper holders in washrooms, and we fix them when they’re loose. Sometimes the mounting flanges have come loose from the wall due to improper installation, or through everyday use (or misuse).
The process of installing of repairing these is fairly straightforward. We mount the towel bar or toilet paper holder in a convenient location for use and make sure it is very solid and tight, and of course that it’s level. Perhaps we are a bit (or a lot) OCD, but we prefer when a toilet paper holder or towel bar has the setscrews accessed from the bottom for the best possible appearance.