I've had this problem for years, all the way back to Lion at least.
I consistently have various emails coming into Apple Mail, that get moved to the junk folder. These emails are not marked as Junk, i.e. Mail does not think they are junk mail, does not highlight them in brown, etc. They cannot be marked as "Not Junk" because Mail already thinks they aren't junk, despite moving them to the junk folder. I can mark them as junk if I want and they highlight in brown as they should, but of course they're not junk so... don't want to do that. I have to manually move them to my inbox every time.
This happens with many accounts coming into Mail, including multiple GMail accounts, multiple accounts using my own personal domain, and my Apple-issued me.com account. So it's not a GMail or 3rd party server thing.
I'm using IMAP for all accounts. Junk filtering is enabled, "trust junk headers in messages" is disabled. This has driven me nuts for years and I'm finally sick enough of it to post a question here. It requires me to carefully scour my junk folder constantly - rendering the whole point of junk filtering moot.
How can I get valid mail to stop going to junk without setting custom rules for every single sender?