In Sun and Moon, major in-game trainers actually are EV trained, and at the various battle facilities such as Tower and Tree over the generations, they have always been so.
Opponents at the Battle Tree draw from a "pool" of about a thousand possible movesets, with each species that's represented getting exactly 4 of those sets, except for Rotom who gets 20 (4 in each non-normal form). Pokemon with Alola forms have those sets split as two in their original form and two from Alola, Oricorio gets one set of each color...but Tornadus, Thundurus, and Landorus have all four of their sets in Incarnate form, with no Therian representation. Each "set" specifies the moves, item, and EV spread, but if there are multiple possible choices for gender or ability, each of those is rolled randomly and can differ between instances of the same set showing up. This has the possibility to produce such humorous effects such as Machamp #4 (which uses a Flame Orb) differing vastly in power depending on whether it rolls Guts as its random ability or not. In general, a Pokemon's sets get more reliable and competitive as you move down the list: Volcarona #1 is content to use Fire Spin trapping (and even has some anti-synergy there with Whirlwind) ahead of a one-time payout like Power Herb Solarbeam, while Volcarona #4 can quickly spiral out of control with Quiver Dance and sweep teams with three different types of special attacks.
The way the actual trainers work, there are about 200 different trainer names, each of which is associated with some number of Pokemon sets from the pool, often as part of a theme team. For example, Rising Star Erix has a sun theme, with lots of Fire and Grass types (the latter usually making use of Sunny Day, Solarbeam, and/or Chlorophyll); Scientist Cadel draws from a pool of very slow Pokemon which will often include some Trick Room setters. Early on in a streak, you'll draw only Trainers that are deemed to have "easy" themes, with sets labeled #1 and sometimes #2 for their respective Pokemon. As you get further (every 10 battles), trainers with more challenging sets are added to the rotation, and the easy ones can eventually rotate out.
The most meaningful switch-up comes at battle #41, where a lot of the earlier trainers are removed from circulation, and the ones that remain use almost exclusively sets numbered 3 or 4. A number of trainers with rosters heavy in legendaries, such as Placido and Priya, also enter the field for the first time at this point (more such trainers are added starting at 51, and the rotation does not change after that). With experience, you'll learn to recognize these themes and adjust your team or playing style accordingly to cope with all those possibilities.
Note that the rotation changes occur on numbers that end in 1, rather than 0, because battles that end in 0 are reserved for so-called "famous trainers". These are trainers that exist either elsewhere in the game, or from previous games (such as Wally, Cynthia, and of course the Battle Legends Red and Blue who will appear on exactly the 50th battle in a Super format, the 20th battle of a non-Super format, and never at any other point). These trainers' rosters generally contain the same Pokemon they're associated with in their respective games, so Cynthia can have things like Garchomp, Lucario, and Milotic on her team. Some of these famous trainers are even version-exclusive: Sun players get to face Kiawe and Plumeria, where Moon players get to face Mallow and Guzma instead. There's also Sina and Dexio: Sina is Sun-exclusive but her theme is "Glaceon plus Pokemon that are version-exclusive to Moon games", while Dexio is Moon-exclusive but his theme is "Espeon plus Pokemon that are version-exclusive to Sun games".