Why do we say "Mazel Tov" when something good happens to a person? Doesn't that mean "good luck?" Are we saying that what happened, happened because of luck?
"Mazal" stems from the root "nazal," meaning "to flow." The basic meaning of the word, then, is not "luck" but rather "something that causes a flow." (It is therefore applied to the heavenly bodies, which in classical Jewish thought are the conduits designed by G-d to exert certain influences on earthly affairs. This then became conflated with the pagan idea that these bodies are independent powers that cause good or bad "luck" - hence the semantic drift.)
R' Shneur Zalman of Liadi, in one of his Chassidic discourses (Likkutei Torah, Haazinu 71d), develops the idea that "mazal," as applied to Jews, refers to the soul's higher spiritual root (compare Talmud, Megillah 3a and Sanhedrin 94a). Through this "mazal" the bearer of the corresponding soul receives the Divine energy that powers his or her physical life, and through it also comes the spiritual awakening that one sometimes feels.
In short, then, when we congratulate someone with "mazal tov," we are acknowledging that he or she has received a heightened level of G-dly bounty, channeled through their "mazal." Possibly, too, we are also thereby implying that we hope that this state of affairs will continue, and that their "mazal" will from now on be more attuned to G-d and will thus be a continued source of blessings.
Rashi in Shabbos 156a, explaining the meaning of the meaning of the Gemorah "There is no Mazel for [Bnei] Yisroel", says that because we can pray therefore Mazel is not final. This suggests that we are bound by mazel, just that there is no finality to it. My teachers explain this to mean that Mazel in this context is a divine decree, therefore when we say "Mazel Tov" what we are saying is that they should merit a good decree from Hashem.
Therefore, we shouldn't ask why aren't we asking Hashem, because we are.
Rav Yosef Messas in his Otzar Michtavim(Siman 362) writes a very similar idea that @Alex mentioned. He notes thathat the phrase was מנזל טוב like the word nozal mentioned in @Alex's answer. However ,since it isn't easy to say מנזל it was changed to מזל,like משיב הרוח was supposed to be מנשיב הרוח originally.
. שאלה: האם יש להמנע מלברך "מזל טוב" או "שיהיה בשעה טובה"?
תשובה: כן, אבל המון העם לא מתכוון למזל ממש, ולכן אין למחות בו.
Question: Should one avoid wishing "Mazal Tov" or "It should be in a good time"?
Response: Yes. However, most people don't refer to actual astrology, and therefore one should not protest against this. (translation my own).
So yes; we should definitely thank God and not ascribe success (or failure) to the stars.