As far as I know, anything that's a bonus doesn't care about when it's added, since boni are separate from actual stats. Think of them as a separate gauge altogether, similar to armor bonuses.
The only randomness I know comes from random stat gains after battle, which can make your final stats vary by about up to 5 points. If you 'fill up' your regular stats before the final experience boost, you get a 0 for your random 'bonus'. That's about the only downside I'm aware of for gym training (but gym training doesn't max stats except for reactions and psi, so this is usually moot) and 'flat' transformations.
'Flat' changes are basically a way to train agents faster. So you get more (or nearly all, in the case of CPT) value from doing that before maxing an agent, and maybe a bit extra from using these to speed up the fulfilment of stat requirements for subsequent transformations. You'll end up in the same place (barring random exp rolls), just faster.
You can kinda see this working by noticing you always get the bonus stats in the transformation UI, but the 'flat' stats ('changes') can be reduced or even go missing if the agent is buff enough.
So, yeah, you get more value (but not higher stats) for doing CPT/MA first, then TNI/Bio. In practice, I've usually had Bio-Enhancement unlocked first, as MA has some stiff stat prerequisites, TNI takes some special missions and manufacturing the implants themselves, and CPT has not been early enough in my research path to become available before BE. Your experience may vary, of course.