why do we say nani o, here instead of just nani?
を - o is the particle that marks the direct object in the sentence
In the text, nani-o is used is used in:
What are you buying/will you buy? (What is a direct object) Nani-o kaimasu ka?
Nani o shimasu ka? What are you doing? / What will you do? Again, what acts as a direct object in this sentence
When used in other functions, the particle that follows would change accordingly
In your text you’ve got:
Nani-ga mondai desu ka? What’s the problem? Here you’ve got “nani-ga” because “what” is the _subject. “Ga” is the particle that marks the subject. Notice that you don’t have “just nani” here either
There are other particles to indicate “with what”, “to what”, etc.
The particles are used with all nouns and pronouns, not only “nani”. They always follow the relevant word
You may want to google “Japanese particles” for extra clarification, for example here’s a “cheat sheet” with the most usual ones:
Fair warning: the function of the “topic marker” wa is oversimplified in the above “cheat sheet” to the point of being misleading. You may want to google for more information about it
Anyway, “wa” would not be used with “nani”, at least not in normal use