It seems that both the words למה and מדוע mean "why". But, I think that there is some other nuance in the meaning of these words; the Torah chooses its words carefully.
Two verses for comparison - Shemot 5:14 uses מדוע and verse 15 uses למה
The translation of מדוע is why. The root is מדע which can be translated as the noun: knowledge, teaching or reason like is found in the Jastrow dictionary.
The usage of למה depends on context. It is a contraction of לשם מה (on account of what). It can also appear in midrash as למה הדבר דומה (to what is the thing similar) like in Kohelet Rabbah 7:13:1.
So למה has more of a connotation of comparison, while מדוע is aimed at the general knowledge or reasoning about something.
This article explains that מדוע appears only in Biblical Hebrew but not in rabbinic Hebrew. It is a contraction of two words מה ידוע - "What is known?" or "For what cause?"
למה has a wider use as it appears in Biblical as well as in rabbinic Hebrew, and is the more common modern Hebrew "colloquial" word. While it can be used to ask about the cause, it is more commonly used to inquire about the purpose of something. it essentially means "for what" as מה means "what".
So, applying this to the above two verses, (my own application):
In the first, the guards see that the same inventory of bricks is not being produced as had been produced before. So, they ask מדוע - what's the reason for the shortage. Some event has happened, what's the reason for it?
In verse 15, people ask Pharoah למה - what's the reason for your treating us this way?
There is a subtle nuance with these two verses, and, I suppose that מדוע could be used in the 2nd verse. Offhand, it seems that מדוע refers to past events, while למה refers to present or ongoing / continuing events or items.
Read the rest of the article regarding the use of למה in Shemot 32:11. The author seems to confirm my thinking, that למה is a question about the future.