it seems to happen with white shirts that, after laundering, have been left in the wardobe for a long time, even though they looked perfectly clean when put away.
I reckon it must be oil from the skin which has oxidised over time. A normal cool wash which makes them look clean is not enough to get rid of the oil.
I make up a paste of persil and water, and rub it into the collars with a nail brush or similar, then give them a HOT wash (if they are cotton).
Mostly people use cool or warm washes, and often washing liquids. An occasional HOT wash makes a big diferrence and restores whiteness.
BTW a HOT wash, pref with lots of cotton towels and no soap powder, will clean away the sludge of old soap, grease and fabsoft that accumulates inside washing machines if you only wash cool. If your towels have an accumulation of soap, you will be surprised to see how well it foams even without adding more powder. If there is no accumulated soap, then a hot wash won't foam.