The key difference between a compound word and a noun used attributively is whether the meaning can be understood from the meanings of the individual words alone.
For example an "egg roll" is a type of Chinese food, with pork, cabbage, ginger (etc) in a wrap and deep fried (egg is not usually an ingredient). Could this be understood from any of the meanings of "egg" and "roll"? I'd say "no", so "egg roll" is a compound noun.
On the other hand "apple pie" is a pie filled with apples. If I knew what "apple" and "pie" mean, I think I could understand the meaning of "apple pie". So this is a noun being used attributively.
A dictionary would need an entry for "egg roll", but it might choose not to have an entry for "apple pie".
There is overlap: Compound words started as ordinary combinations of words, and then the meaning became more specialised. At one time, a "black bird" could be any bird that was black. Later it came to have a specific meaning, and the spelling changed to "blackbird".
All this means for a learner you have to learn that some combinations of words have a specific meaning that can't be guessed from the meanings of the words themselves. Fortunately the meanings are often related and so easy to learn. Many noun+noun compounds are written without a space, so are easy to spot.