I have hunted three or four Anjanaths so far and have never encountered a Rathalos while doing it. So at the very least it's not a scripted thing, but random chance.
That being said, I know the feeling very well, both from earlier installments and from this one. It's frustrating, but also part of the game's way to keep you on your toes.
There are several ways of dealing with it. The simplest is just to stay away until the monsters separate, then follow the Anjanath.
Another way is to use dung bombs (I believe you have to craft dung into dung pods and equip them to the slinger the same way you do the net, but I haven't actually tried it myself yet). Whether you should dung the Anjanoth or the Rathalos is not so easy to answer, though.
The way it worked in earlier installments, with more separated zones, was that if you had already been fighting the Anjanath for a while you should dung that and leave the Rathalos behind. That's because the Anjanath would probably run away soon anyways, while the Rathalos would stay in combat mode for a few minutes, unable to run. I don't know enough about the monster psychology (specifically how tied they feel to the different areas of the map, both when roaming and when fighting) to answer that question for World, though.