I could quite easily flag the question as a duplicate and move on, however, because of the way the question has been asked we can probably assume that the asker has a very basic knowledge of programming and they may struggle to understand the duplicate answer.
If it's a duplicate, it's a duplicate. When you know that a question can be answered by the answers to another question (the object they ask for or the problem about is equal) then flag/vote to close the question as duplicate. No matter whether the OP might understand it at the moment or not.
Maybe s/he do not understand it at the moment but the duplicate question and the answers there are very helpful when s/he is be able to understand it.
In the case of not duping, the questioner[and others] might lose a very helpful reference for his/their education.
If you feel the answers to the duplicate doesn't answer the actual question very well, try to improve the duplicate by f.e. giving more insights about specific edge cases.
"My answer added a bit of an explanation and an example of how to solve their specific issue, which is useful to the asker but is unlikely to be useful to anyone else (based on the title) coming to Stack Overflow."
However, there is nothing wrong to gave a short customized answer to a custom question. To helping others is the purpose of this whole network.
Explain the specific problems, but avoid to explain in detail what already is best explained at the answers of the duplicate.
"Should I have flagged the question to be closed as a duplicate?"
Yes.
"Should I downvote the question and add a comment?"
Your choice. Note that I personally don't like to just downvote questions because they are duplicates. I judge upon the quality of the content of the question itself to maybe suggest myself to downvote.
I consider myself often in the situation, that I just don't got the information I wanted after a long research. Just downvoting because I didn't know about something or didn't find something out, feels inappropriate.
Nonetheless, I also don't like questions which really ask for very basic things.
So at the end, I decide at the specific case, if I downvote or not.
"or was it appropriate to answer the question as I have done with some helpful points while still linking to the duplicate for additional understanding?
Yes, absolutely.
Summary:
You can give a short and custom answer to a custom question, but don't try to cover entirely things which are explained at the duplicate.
If you think the answers at the duplicate are not so good or could be better, improve the canonical duplicate and place your own answer there.