I found a publication by “La Crusca per voi” where a correspondent asked the Accademia della Crusca why “prego” is used in this manner in Italian. The response to that question was written by linguist Giovanni Nencioni.
I will provide an English translation below.
The word prego after grazie is characteristic of courtesy. I would like to know how it entered into use and if it has a connection to prayer.
There is no doubt that the verb pregare [to pray] originally had, and continues to have in appropriate contexts, a religious meaning. But we need not attribute that denotation to simple human rapport as well: even mortals si pregano [are prayed to, are beseeched], and in that case the meaning of the verb, strong or weak as it may be, sheds the sacral character that characterizes the appeal to divinity.
The attenuation or semantic emptying of sacred expressions is a widespread fact: when the Romans exclaimed mehercules they did not intend to invoke the deified hero Hercules, but to affirm energetically: indeed! of course!. When I extract old expressions from memory like per Giove! [by Jupiter!], per Bacco! [by Bacchus!], I express surprise, resistance, or even enthusiasm; I certainly do not call into question two mythological divinities. I remember hearing from atheists with various degrees of emotion Madonna! [Mary!] Perdio! [for God's sake], without realizing a possible contradiction. The contradiction effectively did not exist, because these expressions were reduced to simple interjections, that is, utterances of voice aimed at expressing a state of mind, therefore devoid of contextual reference.
While not an exclamation, the first person form of the present indicative of the verb pregare is a courteous form of communication, and is registered as a word by itself in modern dictionaries.
In the rest of his response, Nencioni quotes the definition of the word “prego” in various dictionaries and discusses the nuances of its meaning. So, I did not translate that part.