I don't use the archive button through a web browser. the only thing I do when I access gmail through web browser is to mark spam messages as I'm not using the apple mail junk folder as it doesn't work.I rebuilt the mailbox - no result.
I found that I get better results for SPAM by using SpamSieve as a "replacement" for the Mail app's junk folder.
Only the newer ones - that also don't allow me to chose "archive" as the mailbox for archived mail, but only have the option "gmail all mail" . Why? I suppose this is the problem.
Again, the email folders that you configure on the Mailbox Behaviors tab are Gmail's folders, not something that Apple creates. The tab basically allows you to "point" to the Gmail folders for each of the email features (Inbox, Drafts, Spam, etc.) Gmail defaults to the "All Mail" folder for archived messages. This may be something that Google changed recently, I don't know. I mainly use my Gmail account as a SPAM "catcher."
Which folders you have in Gmail are initially created by your Gmail account. You then have the ability to add or make changes to these as needed by going through your Gmail user account.