In simple words because the enemy forces were seriously STRONG that ANBU agents were not able to defeat them (as said by Happy Face in the comments).
According to me, Naruto's team is an exceptionally very strong.
Kyuubi's Chakra + Sharingan + Healing = STRONGEST
So there is no doubt that they are stronger. They are exceptionally strong, so we might say that they are stronger than ANBU agents.
When some strong enemies come to their village let's say Nagato, aka Pain, then it's quite obvious that ANBU agents won't be able to defeat him because Nagato is really strong, but Naruto did because he is exceptionally stronger than the ANBU agents.
According to wiki :
One of the Fifth Hokage's ANBU bodyguards attributed his chakra supply to the Rinnegan. Nagato could also constantly alter the nature of his chakra to prevent him from being located by sensory type ninjas.
This is also written in wiki that:
ANBU commander is very observant, seen when he recognises that Pain's chakra-levels must be immense and that he is controlling the bodies used to destroy Konoha by chakra alone.
But that doesn't mean that all anbu agents are nothing. For example Yamato is also an ANBU agent, and if you have seen him then you may have know that he is not easy to be defeated by enemies just because he is strong.
There are many ANBU agents which differ from each other. They are responsible for carrying out assassinations, tracking, surveillance, and missions requiring specially trained ninja. Also some ANBU serve as interrogators.
All ANBU agents have their own skills.
But there's a point that we must note:
ANBU are expected to destroy their bodies when they are badly injured on a mission like that they won't be captured.
Which might explain why they kill themselves every time they are badly hurt. Source