The key is to remember codes define “barely good enough.” Codes are not meant to define “best” or plan for every situation. (This has a corollary: Those who cleverly seek out “code minimum” are ignoring their duty to build for the job — not the code).

I’ve mounted miles of EMT and thousands of boxes on drywall using those plastic anchors. Until recently I had no cause to question the practice. Then I moved to Arkansas.
The local combination of aged drywall and constant humidity has resulted in anchors easily pulling free after about ten years. Unsatisfactory by MY standards, especially if there is anything heavier than a small picture hanging from the anchors.

Of greater concern to me is the part of the code with the vague requirement that wires be protected from mechanical and environmental damage. This can mean that there is no method that is acceptable— by my standards, at least. (My position has made me most unwelcome at some locations).
Back on point: IMO box placement is the first concern with the anchoring method chosen to suit. Not all drywall is the same (some is designed to be stronger, harder, and more moisture resistant than other varieties) and not every anchor faces the same loads. For example, a box with a light switch won’t see the same loads as one with hospital grade plugs in it.

The most common method is to have the carpenter place wood behind the wall; long screws get the job done.

“Good practice” aside, I hold that determining anchoring methods and box placement is outside the scope of the code. Most relevant code language is unenforceable. You’re an inspector and not a king.