It's frustrated me for years, Junk filtering disabled but sporadically an email would end up the in the Apple Mail spam box. But based on the gmail questions I've seen, I went into my gmail web interface and sure enough, gmail had filtered this particular email into the gmail spam box. Apple just brought the same email forward to the Apple Mail spam box.
What wasn't clear is why it selectively brings emails forward from some accounts and not others. Time will tell but I think I found that out as well. Turns out it is a setting specific to each account setup in Apple Mail. I went into Apple Mail preferences > accounts > mailbox behaviors tab. For some reason on the one account that would occasionally bring junk mail forward from gmail to apple mail, the gmail account in question had 'junk folder' had [Gmail]/Spam selected from the dropdown list. All others had Spam selected. Interestingly, it didn't match the other gmail accounts, but switching it to On My Mac > Junk fixed the issue. Maybe it will work for some other people as well.