Considering the verse mentioned at the surface level, we deduce that it is permissible to build mosques over graves. In the exegesis of the Quran, it is mentioned that a mosque has been built over the cemetery of the people in the cave (Al-Kahf).
In the related tradition, there is a prohibition of building mosques in these places. But a thorough study of this verse and these traditions results in that these traditions ensure one thing along with the prohibition which is not to alter the graves into a place for idolatry and paganism instead of worshiping Allah (swt). Though the grave is in the direction of the prayer it will be considered right, because the prayer is not affected in case there are buildings or graves in between the person who is praying and the direction of the prayer.
Your question can be diversified into sub-questions and each one should be studied alone to reach up a complete and perfect answer.
1- Does the verse in the chapter of Al-Kahf refer to the origin of building mosques over graves or not?
2- Is it possible that there are some particular sites of a particular value that makes them places of blessing?
3- Does praying to Allah (swt) beside graves contradict with worshiping Him, even when we consider that the grave is in the direction of the prayer? What is the opinion of the Shiite in this issue with regards of what the Imams say about that?
Concerning the first part related to the verse 21 of the chapter of Al-Kahf; which the questioner referred to mistakenly as 33, the verse obviously declare that the believers insisted on building a mosque over the cemetery of the people in the cave, there was no objection or criticism of that in the Quran. If this act contradicts with the creed and principles of religion, the Quran would have rebuked them for doing it, and would refer to their deviancy from truth. Besides, this historical fact is related in the books of the Sunnis as well; in some of these books and after the exegesis of the verse «We verily shall build a place of worship over them» there are traditions mentioned denote the fact of the prohibition of building mosques over graves. Similarly, such traditions are related in the books of the Shia.
This caused a dispute amongst the scholars and thinkers, trying to resolve the issue without disregarding the clear denotation of the verse which authorizes the building of mosques over graves, and simultaneously take into consideration these related traditions which on the other hand prohibit this act. There should be a joining of the verse and the traditions to avoid the contradiction.
Some Sunni scholars justified the prohibition of building mosques over graves as follows: those who built a mosque over the graves of the people of cave are infidels (disbelievers), even if they were believers, their act is considered undesirable. In joining them in such a manner it appears that the surface meaning of the verse is being avoided and it is an attempt to cancel the whole issue. But as said before, not rebuking those people for this act is an evidence that the Quran upholds them.
Al- Majlisi, a great Shia scholar, joined the verse and the related tradition as follows:
(May the Jews and the Christians be damned for making their prophet's graves places of worship), they used to direct their prayer towards these graves, as if they are idols. However, those who build mosques beside the grave of a righteous man or pray in a cemetery intending to gain a blessing from that and not for the purpose of glorifying the dead in the grave will not be wronged. Do you not realize that Ismail's grave is in the sacred sanctuary and the prayer performed in its spot is greatly rewarded?).
Other Sunni scholars took this issue into consideration, saying that these traditions do not contradicts with the permissibility of building mosques over graves and seeking blessing in them.
To conclude, the purpose of building mosques over graves should not be to take them as places of idolatry and paganism, a fact emphasized in the tradition of the Prophet (pbuh): (Oh Allah, let not my grave be an idol of worship).
However, building mosques around the graves and praying inside them in the direction that Allah (swt) has decreed for us is not a problem.
The other evidence that could sustain this matter is that the Prophet and two of his companions were buried in a spot near the Prophet's mosque. In the last enlargement, the graves became inside the sanctuary, yet no scholar prohibited praying inside the mosque on account of the three graves, and no one referred to any of the prohibitive traditions as well. In addition to that, the prayer performed in the sanctuary of the Prophet's mosque does not differ from that being performed in the Imams' shrines.
In viewing the second part of the question there should be a thorough study and analysis of some issues. As Muslims we believe that:
1- Allah (swt) is not restricted to a certain place or direction, «Unto Allah belong the East and the West, and whithersoever ye turn, there is Allah's Countenance».
2- Allah (swt) has defined a particular place for people to orient themselves to in the prayer on account of organizing their worship. Muslims in the time of the Prophet prayed in two different directions, one of them being towards the sacred mosque in Jerusalem, the other being towards Mecca. In other words, the direction of the prayer does not retain a value in itself, but its value comes from its being a means to worship and obey Allah (swt); a fact that has been explicitly referred to in the Quran.
3- We, as Muslims, never prostrate to any one but Allah (swt) as the Imams enjoined us to do. And as for prostrating towards a person or a definite thing, it does not mean that we worship that thing; our prostration towards the Kaaba does not signify that we are specifically worshiping it. Do we intend to worship Allah (swt) or the Kaaba when we prostrate towards it? And when Allah (swt) enjoined the Angels to prostrate before Adam, was that to lead them to associate with him (Allah forbids); therefore, Satan is the only monotheist when he refuses to prostrate and he is the only one to succeed in this test, while the Angels abandoned the worship of Allah (swt) and turned to be Adam's worshippers?!
We believe that prostration is an act that shows obedience to Allah (swt), and when He orders us to perform it before someone else we submit to that, considering it to be part of our submission to Him and disobeying Allah (swt) in doing that means that we are associating with Him. Besides, our obedience in directing our prayer towards the Kaaba does not mean that our prostration is not for Allah (swt).
4- We also believe, as Muslims, that the heavens and the earth belong to Allah (swt) and that performing some acts of worship in some particular sites brings back much greater reward than their being performed in other places, such sites are the sanctuary in Mecca and the Prophet's mosque in Medina, where they have privilege over other places in regard to the worship being performed in them. The Prophet says in that: (A prayer performed in my mosque is much rewarded than in any other mosque except for the Sacred Sanctuary).
In the Shiite creed, the prayer and the worship bring greater reward once they are done in the Imam's (a) shrines as well as the sites mentioned above. And the restrictions in which these acts are shaped in show no sign of association with Allah (swt).
It is not relevant to mention the benefits of visiting these shrines, as it is not part of your question but if you have any interest in being acquainted with them you may go to the research that has been done regarding this matter; one of them is question number
As for the third part of the question we may point to some traditions related to this topic:
1- (Al-moqdadi narrated that Imam Zain Al- Abedeen (p) arrived in Kufa and entered its mosque, where Abu Hamza Al-Thumali was there; one of the most devoted worshippers in Kufa. He prayed and supplicated, until he said: then I followed him to the wilderness of Kufa, where I saw a black slave with a camel, I asked: O slave! who is this man? He replied: Have not you recognized him? He is Ali Bin Al-Hussain (a). Abu Hamza said: I knelt down at his feet kissing them, then he raised my head and said: (No, Abu Hamza, prostration is only before Allah (swt) be He Glorified, I said: O son of Prophet why did you come to us? He said: Because of what I have seen, had the people known the great reward in it they would have crept to attain it) 
2- (Abu al-Yessa narrated: a man asked Abu Abdullah and I was listening, he said: If I arrived at Al-Hussein's grave (p) shall I make it the direction of my prayer? He said: step aside the grave).
3- There are traditions which indeed recommend the visitors of the shrines to stand in the side of the head when praying in the sanctuary, which means that if someone is honored by visiting the Imams, it is good for them to know that the side of the head is the best to perform the prayer in. The purpose behind that is to show reverence to the Imams because standing to pray where the grave is behind you is a sign of disrespect to those great people. Apparently some people understood that to be enjoining the visitors to prostrate before the graves, while in reality people are praying near the shrines in the direction decreed for them to follow by Allah (swt); which is the Kaaba. These traditions aims at denoting that showing respect to the Prophet and the Imams is a desirable thing whether in their lives or after their deaths. It also believed that their position and rank are much greater than that of the martyrs mentioned in the Quran to be alive.
Based on what is said previously we think that the Prophet and the Imams listen to us when we visit them, and reply to our greeting, which is not to say that we are heedless of Allah (swt). The Imams commanded the believers to begin the recitation of the Al-Jamia prayer (الزیارة الجامعة) with the reptition of (Allah is the Greatest) a hundered times.
Moreover, respecting The Prophet and the Imams and visiting their graves after their death do not intermingle with worshipping Allah (swt).
Finally, we reach up to a result that performing the prayer or even supplicating near the shrines of those great people is permissible, being aware of the nessecity to reflect at their lives and struggles as they are elevated people.
What you said about the direction of the prayer and its being sometimes in the same direction of the graves is right. But do you think that a person who is praying in the sanctuary should change his place; though he is directing his prayer to the Kaba, just to keep praying beside the shrine while the sanctuary is crowded with people and he can barely find a foothold? This has not been even confirmed by any of the Muslims sects. There are strong related Traditions which order us not to make the graves the intended direction we are praying to, and yet no one talked about the prayer being unrighteous in such cases.
If the worshippers in the shrines prayed in the direction of the graves forming a circle as the worshippers do in the sanctuary of the Kaaba then it is possible to accuse them and consider them to be prostrating before the graves. But when they are performing their prayer in a shrine where the grave happened to be in the direction of the prayer, then it is not a problem at all, and insisting to accuse them is unfair as well as arrogant. What would you say about the people praying with Ibrahim's place facing them? Do we say that they are praying before the place or the Kaaba?
There are some ignorant people who deviate completely from the direction of the Kaaba; their prayer is not only considered wrong by the Shiite, but they are also condemned and avoided from doing that and having such rare cases is not to say that they only belong to the Shiite sect.
 Tabari, Abu Jafer Mohammed bin Jareer, Jame Al Bayan Fi Tafseer al Quran, vol 15, pg 149, Al Ma’arif Publishing, Beirut, 1412 H.
 Qurdubi, Mohammed bin Ahmed, Al Jame Le Ahkam Al Quran, vol 11, pg 379, Naser Khosro publishing, Tehran, 1364 H S.
 For example: Refer to: Al Sheikh Al Sadooq, Man la yahdoroho al faqeeh, vol 1, pg 178, Tradition 532, Islamic publishing institution, Qum, 1413 H.
 Qurdubi, vol 11, pg 379.
 Ibn Katheer, Exegesis of the great Quran, vol 5, pages 133 - 134, Scientific Books Publishing, Beirut, 1419 H.
 Majlisi, Mohammed Baqer, Bihar Al Anwar, vol 79, pg 56, Alwafa Publishing, Beirut, 1404 H.
 Al Modheri, Mohammed Thanaa Allah, Al Modheri exegesis, vol 6, pg 25, Roshdiya library, Pakistan, 1412 H.
 Qurdubi, Mohammed bin Ahmed, Al Jame Le Ahkam Al Quran, vol 11, pg 379.
 Chapter Al Baqara, 115.
 Chapter Al Baqara, 142 - 145.
 Chapters: Al Baqara, 34; Al Araf, 11; Al Esra, 61; Al Kahf, 50; etc….
 Qurdubi, Mohammed bin Ahmed, Al Jame Le Ahkam Al Quran, vol 10, pg 372.
 Al Horr Al Ameli, Mohammed bin Al Hacen, Wasael As Sheaa, vol 14, pages 407 - 408, Tradition 19474, Ahlulbayt institution, Qum, 1409 H.
 Ibid, vol 14, pg 519, Tradition 19731.
 Ibid, vol 14, pg 519, Tradition 19730, and pg 520, Tradition 19732.
 Chapter Al-Emran, 169.
 Majlisi, Bihar Al Anwar, vol 99, pg 127.