«أَخَذْتُ مَا أَعْطَيْتَنِي» — I took what you gave me: relative «مَا» as object, with an omitted returning object of «أَعْطَيْتَ».
«مَا هَذَا؟» — What is this? Here «مَا» is interrogative, not relative.
Distinguish a question from a relative construction with a ṣilah.