The physio (orange jersey) is allowed on the pitch at any time to attend to injured players.
The trainer (yellow jersey) is allowed on the pitch when the team is in possession of the ball, to make an interchange. They must only stay on the pitch for a maximum of three play the balls. They cannot go on the pitch to only take messages on, but teams get around this by sending their physio with messages as they can go on at any time.
Some teams play by the rules and the trainer goes on when they are allowed, some teams send their trainer on whenever and leave it upto the officials to tell them not to go on.