什么 means what
吗 is a common interrogative pronoun meaning “yes or no”. We always put 吗 in the end to make it a question.
你有什么事吗?Literally it means “what matters do you have”.
Most of the time, It is a general inquiry. For example, when I make a consultation call, I will hear such a sentence meaning “what can I help you?”.
And sometimes it contains a tone of impatience. It’s more like ”what’s wrong with you?”.