Both are correct ways to express the same idea. The only difference is the phrasing.
The first sentence, if translated directly, is like saying:
"That; whose bag is that?"
The second says:
"That bag; whose is it?"
These are very direct and somewhat unnatural translations, so you could simply translate it as:
"Whose bag is that?"
As for the particles の and は, they can have a few different meanings depending on context. I will explain how they function in this context only. All particles simply have a grammatical function or affect the mood of the sentence in some way; They have absolutely no meaning on their own. They must be connected with other words in the sentence.
は, in this case, calls attention to something or identifies the topic of something. The topic in each of these sentences being "that" or "that bag." Sometimes は indicates the subject of a sentence, but this is not always so. は is often described as a "topic marker."
の, in almost all cases, indicates possession or the relationship between two objects. So, in this sentence, の is attached to だれ. だれ, by itself, means "who," while だれの means "whose." Similarly, if you take the pronoun わたし (meaning "I") and attach の to it, you get わたしの meaning "my."
I hope this helps! If you have any further questions about Japanese grammar, please let me know. :D