Never did the Rambam understand this declaration as a "prayer" nor at any time did he deem requests or favors be permissible to ask of mal'akhim ("angels").
In an article written for the monthly newsletter of Makhon Mosheh and Halikhoth `Am Yisra'el - Or HeHalikhoth - by Rabbi Dr. Hhananel Sari (Shevat, 5773), the position of the Rambam from his own writings is explanation as regards the nature of mal'akhim and specifically the purpose and identity those that are constantly referred to by Hazal as accompanying each person.
...the mal'akhei ha-shareth that the gemara describes such as that they accompany a person [home from the beth kenesseth] on Shabbath, they appear to be the same mal'akhim that are mentioned in other places in the words of Hazal. They testify to the deeds of a person if he acts in a way that is not appropriate (cf. Ta`anith 11a), and from them it seems that a person needs to separate with apologies before they enter to perform their needs (i.e. use the bathroom - cf. Berakhoth 60b). The Shulhhan Arukh writes that today we no longer have the custom to say this apology, called "hithkhabdu mekhubadim" (OH 3:1), since we are not so strong in our yirath shamayyim that mal'akhim accompany us (cf. Mishnah Berurah). In the sefer "Kaf HaHhayyim" an opinion is brought in opposition to this that there are mequbalim who recommend to say it also in our times, since these mal'akhim continue to accompany each person also today. This mahhloqeth, whether or not mal'akhim still accompany people in our generation and if it is feasible to turn to them, for they comment on their observation that it accomplishes not only a positive assistance but it is also involved in [promoting] a more meticulous inspection of our deeds, these are debated due to a conception of mal'akhim which is far removed from that of the Rambam. In the Moreh Nevukhim (2:6, 3:22) the Rambam, in dealing with the explanation of the nature of mal'akhim, mentions that the meaning of the "mal'akh" is not always consistent, however the basic meaning is always "shaliahh". Because of this, each navi is worthy of being called by this name and even forces of nature through which HaQadhosh Barukh Hu manages His world, all of them are worthy to be called "mal'akhim" and they are known as the pamalya shel ma'alah (i.e. the entourage of HaQadhosh Barukh Hu). After this introduction, the Rambam brings a passage from Midrash Qoheleth that tells how when a person sleeps "nafsho omereth le-mal'akh umal'akh omer le-keruv - his soul speaks to the 'angel' and the angel speaks to the 'cherub'." And from here he learns that in the language of Hazal the creative faculty of a person is called a "mal'akh" ('angel') and his intelligence is called "keruv" ('cherub'). The Rambam knew that the majority of people were not accustomed to designating these parts of the soul as being mal'akhim and would even resist to accept this fact, therefore continues and says, "How important this is for the one who knows, and how ugly it is to those who are fools." We find therefore who these mal'akhim are according to the Rambam that accompany a person to every place that he goes, and it is clear now that in his opinion each person is accompanied by these two mal'akhim also in our times. Now it only reamins to clarify who is the "evil mal'akh" and who is the "good mal'akh." The question is not so difficult, yet the Rambam also deals with this question, but in another chapter of the Moreh (2:12).
Making requests - either for intercession or favors - from objects or beings other than HaShem is a violation of the 5th principle of Jewish faith and is the basis of all idolatry. Even nevi'im who receive their prophecies through the agency of a mal'akh don't ever make requests of them. Instead, they pray directly to God and allow God to use whatever means He deems necessary.
This particular statement amounts to little more than reminding one to hold off thinking holy and religiously constructive thoughts while in the bathroom until he finishes and exits. There is no prayer here and the phrases of "help me" and "guard me" etc. are later additions made by those who took this statement as a prayer to angels for protection from demons that supposedly live in the bathroom.
Hope this helps. Kol tuv.