Was Prophet Muhammad (SAW) a polytheist like others in the Quraish tribe or did he always believe in One God or was he even religious at all?
Before the revelation the prophet pbuh was not known for having followed any of the pagan believes and for rejecting them and rejecting even accepting their deities or to swear by their names. He is said to have been following the (true) religion of Ibrahim this can be found in the long sahih narrations of al-Bukhari here and here and that of Sahih Muslim... here an extract from it:
The first (form) with which was started the revelation to the Messenger of Allah was the true vision in sleep. And he did not see any vision but it came like the bright gleam of dawn. Thenceforth solitude became dear to him and he used to seclude himself in the cave of Hira', where he would engage in tahannuth (and that is a worship for a number of nights) before returning to his family and getting provisions again for this purpose. He would then return to Khadija and take provisions for a like period, till Truth came upon him while he was in the cave of Hira'. ...
in these narrations the word يَتَحَنَّثُ was used and interpreted as worshiphing, but in the narration of ibn Hisham it appears as يَتَحَنَّفُ which refers to the religion of 'Ibraheem as it appears in the qur'an:
مِلَّةَ إِبْرَاهِيمَ حَنِيفًا the religion of Abraham, inclining toward truth
in several verses such as (2:135), (3:95), (4:125), (6:161) and (16:123).
Ibn Hajar in his commentary on Sahih al-Bukhari (see here in Arabic)when discussing the hadith explained that يَتَحَنَّثُ has two meanings:
The first is يَتَحَنَّفُ and means follows the religion of Ibraheem and the letter ف was replaced by a ث which is common in the Arabic language.
The second is that comes as a synonym of to avoid sin يتجنب الحنث
The prophet pbuh was also never involved in any haram action for example when he ever went to a wedding party Allah made him fall asleep or lose conciousness nor did he ever drink alcohol etc.
You may further read in the seerah books for example in al-Mubrakpuris ar-Raheeq al-Makhtum pages 64 - 67: the two chapters entitled: subchapter A RAPID REVIEW OF MUHAMMAD'S BIOGRAPHY BEFORE COMMISSIONING OF THE PROPHETHOOD and Chapter IN THE SHADE OF THE MESSAGE AND PROPHETHOOD subchapter IN THE CAVE HIRA (I've added a link to a Sahih Hadith):
A RAPID REVIEW OF MUHAMMAD'S BIOGRAPHY BEFORE COMMISSIONING OF THE PROPHETHOOD:
Prophet Muhammad (Peace be upon him) was, in his youth, a combination of the best social attributes. He was an exemplary man of weighty mind and faultless insight. He was favoured with intelligence, originality of thought and accurate choice of the means leading to accurate goals. His long silence helped favourably in his habit of meditation and deep investigation into the truth. His vivid mind and pure nature were helpfully instrumental in assimilating and comprehending ways of life and people, individual and community-wise. He shunned superstitious practices but took an active part in constructive and useful dealings, otherwise, he would have recourse to his self-consecrated solitude. He kept himself aloof from drinking wine, eating meat slaughtered on stone altars, or attending idolatrous festivals. He held the idols in extreme aversion and most abhorrence. He could never tolerate someone swearing by Al-Lat and Al-'Uzza. Allâh's providence, no doubts, detached him from all abominable or evil practices. Even when he tried to obey his instinct to enjoy some life pleasures or follow some irrespectable traditions, Allâh’s providence intervened to curb any lapse in this course.
Ibn Al-Atheer reported Muhammad (Peace be upon him) as saying: “I have never tried to do what my people do except for two times. Every time Allâh intervened and checked me from doing so and I never did that again. Once I told my fellow-shepherd to take care of my sheep when we were in the upper part of Makkah. I wanted to go down to Makkah and entertain myself as the young men did. I went down to the first house of Makkah where I heard music. I entered and asked: "What is this?" Someone answered: "It is a wedding party." I sat down and listened but soon went into deep sleep. I was awakened by the heat of the sun. I went back to my fellow-shepherd and told him of what had happened to me. I have never tried it again.”
Al-Bukhari reported on the authority of Jabir bin 'Abdullah that he said: “While the people were rebuilding Al-Ka'bah, the Prophet Muhammad (Peace be upon him) went with 'Abbas to carry some stones. 'Abbas said: "Put your loincloth round your neck to protect you from the stones." (As he did that) the Prophet (Peace be upon him) fell to the ground and his eyes turned skyward. Later on he woke up and shouted: ‘My loincloth... my loincloth.’ He wrapped himself in his loincloth.” In another report: “His loins were never seen afterwards.”
The authorities agree in ascribing to the youth of Muhammad (Peace be upon him) modesty of deportment, virtuous behaviour and graceful manners. He proved himself to be the ideal of manhood, and to possess a spotless character. He was the most obliging to his compatriots, the most honest in his talk and the mildest in temper. He was the most gentle-hearted, chaste, hospitable and always impressed people by his piety-inspiring countenance. He was the most truthful and the best to keep covenant. His fellow-citizens, by common consent, gave him the title of Al-'Ameen (trustworthy). The Mother of believers, Khadijah (May Allah be pleased with her) once said: He unites uterine relations, he helps the poor and the needy, he entertains the guests and endures hardships in the path of truthfulness.
IN THE SHADE OF THE MESSAGE AND PROPHETHOOD
IN THE CAVE HIRA:
When Prophet Muhammad (Peace be upon him) was nearly forty, he had been wont to pass long hours in retirement meditating and speculating over all aspects of creation around him. This meditative temperament helped to widen the mental gap between him and his compatriots. He used to provide himself with Sawiq (barley porridge) and water and then directly head for the hills and ravines in the neighbourhood of Makkah. One of these in particular was his favourite resort — a cave named Hira’, in the Mount An-Nour. It was only two miles from Makkah, a small cave 4 yards long and 1.75 yard wide. He would always go there and invite wayfarers to share him his modest provision. He used to devote most of his time, and Ramadan in particular, to worship and meditation on the universe around him. His heart was restless about the moral evils and idolatry that were rampant among his people; he was as yet helpless because no definite course, or specific approach had been available for him to follow and rectify the ill practices around him. This solitude attended with this sort of contemplative approach must be understood in its Divine perspective. It was a preliminary stage to the period of grave responsibilities that he was to shoulder very soon.
Privacy and detachment from the impurities of life were two indispensable prerequisites for the Prophet’s soul to come into close communion with the Unseen Power that lies behind all aspects of existence in this infinite universe. It was a rich period of privacy which lasted for three years and ushered in a new era, of indissoluble contact with that Power.
Before the prophet became a prophet, he was known for not having ever worshipped the idols but still being regarded by his citzens as the as-saadiq al ameen the truthful the trustworthy
The messenger of Allaah, Muhammad ibn Abd-Allaah ibn Abd al-Muttalib al-Haashimi al-Qurashi was born in Makkah in the year of the Elephant ...
... Allaah made Muhammad grow in a good manner, and Allaah took care of him, so he was the the best of his people in physical wellbeing and in attitude, he was the most generous, the most patient, the most truthful, the most sincere and the most honest, so his people called him al-Ameen (the trustworthy) . ...
... Then he was given an inclination towards solitude, so he used to spend many days and nights alone in the cave of Hiraa’, worshiping and praying to his Lord. He hated idols, alcohol and promiscuous conduct, so he never paid any attention to them all his life ...
...When shirk and corruption became so widespread, Allaah sent Muhammad (peace and blessings of Allaah be upon him), when he was forty years old, to call the people to worship Allaah Alone and to give up idol-worship. Quraysh denounced him for that...
source - https://islamqa.info/en/11575
thus the prophet always had a realistic idea of the world and that the idols are not worthy of worship because they are not true gods, thus it seems that his religious point of view was realistic although he did not know about Allaah fully, he hated evil and stayed away from committing it
and Allaah knows best.