Does a gene code for protein molecules or a DNA codes for protein molecules?
Your understanding is correct in that DNA encodes RNA, and this is a one-to-one relationship generally (although there are exceptions, see link below).  However, a given RNA can encode myriad proteins via translation.  This is because of different translation start sites and splicing of RNA.  You can read about this relationship between DNA/RNA/protein (the 'central dogma' of molecular biology), here:

https://en.wikipedia.org/wiki/Central_dogma_of_molecular_biology

But in the title of the quesiton you also ask about whether a gene or DNA encodes protein.  A gene is comprised of DNA; if someone talks about a gene, this just means a transcribed sequence, i.e. a region of DNA that is made into RNA.  Whether or not this is then translated does not impact its definition as a gene.  If it is transcribed, you could call it a 'protein-coding gene', otherwise you can call it a 'non-coding gene'.