Your original sentence is correct.
This is an example of parallelism. If you wrote it out in full you would need to repeat "why does". English grammar often allows for repeated phrases to be deleted in the second phrase, but other words should be written as if they were there.
So in full
Why does “singer” have /ŋ/, and why does “longer” have /ŋg/?
becomes
Why does “singer” have /ŋ/ and “longer” have /ŋg/?
When the parallel phrase "why does" is removed.
You could go further and also remove have.
Why does “singer” have /ŋ/ and “longer” /ŋg/?
But now there are two different deletions at two places and it is that much harder to understand (your brain needs to work harder to put "why does" in before "longer" and "have" after it.) So your original sentence is the best compromise between being short and being easy to understand.