There is a hadith or is it Quranic ayat which says 'don't select those as ruler who have intentions to be rulers'? Please give reference.
There are a few ahadith that go ahead with the meaning you quoted:
Two men from my tribe and I entered upon the Prophet. One of the two men said to the Prophet, "O Allah's Messenger (ﷺ)! Appoint me as a governor," and so did the second. The Prophet (ﷺ) said, "We do not assign the authority of ruling to those who ask for it, nor to those who are keen to have it." (Sahih al-Bukhari and Sahih Muslim)
The Messenger of Allah (ﷺ) said to me: 'Abd al-Rahman, do not ask for a position of authority, for if you are granted this position as a result of your asking for it, you will be left alone (without God's help to discharge the responsibilities attendant thereon), and it you are granted it without making any request for it, you will be helped (by God in the discharge of your duties).
(Sahih al-Bukhari Version 1, 2, 3 and 4, Sahih Muslim Version 1 and 2, Sunan abi Dawod, Sunan an-Nasa-i, Sunan ibn Majah and Jami' at-Tirmidhi)
The Prophet (ﷺ) said: If anyone desires the office of Judge and seeks help for it, he will be left to his own devices; if anyone does not desire it, nor does he seek help for it, Allah will send down an angel who will direct him aright. (Sunan abi Dawod)
These are just a couple of ahadith on this topic and the wording might differ from one hadith compilation to another and there are similar narrations in other compilations too (like Musnad Ahmad, Sunan al-Bayhaqi al-Kubra and the three encyclopaedia's of at-Tabarani).
The understanding of scholars is that it is frowned upon to seek or ask for a high position, like that of a ruler or a judge, but this doesn't mean that the right and just person shouldn't do so as Allah shows us in the Qur'an:
[Joseph] said, "Appoint me over the storehouses of the land. Indeed, I will be a knowing guardian." (12:55).
He said, "My Lord, forgive me and grant me a kingdom such as will not belong to anyone after me. Indeed, You are the Bestower." (38:35)
and in the sunnah you may find an explanative hadith:
The Prophet (ﷺ) said: If anyone seeks the office of judge among Muslims till he gets it and his justice prevails over his tyranny, he will go to Paradise; but the man whose tyranny prevails over his justice will go to Hell. (Sunan abi Dawod)