It is highly unlikely that they are recognizing MHC-II as the self-antigen. I'll explain why in a minute. But back to your original question, just because an antigen is extracellular (which is the type loaded onto MHC-II), does not mean it is foreign. Tons of potential self-antigens are in the extracellular milieu and can range from cellular debris, to proteins liberated by pathological conditions, to plasma proteins. You may even have complex antigens that include both foreign and self components. All of these things have the potential to be engulfed by APCs which are phagocytic cells (for example, cellular debris could be cleared by macrophages and subsequently presented) and then presented on MHC-II on their surfaces. Phagocytosis is generally not a selective process that only takes up foreign material.
Now back to the question of why it's unlikely that MHC-II itself is recognized. T lymphocyte maturation in the thymus takes place in stages. Specifically there's positive selection and negative selection. In positive selection, only the T cells that can bind MHC receives survival signal, which ensures that all mature T cells are competent to recognize MHC complexes and the antigens loaded on them. In negative selection, those T cells that bind very tightly to a selection of self-antigens are clonally deleted which is also referred to as central tolerance. In the case of MHC-II, the way I think about it is, all T cells have the ability to bind MHC-II. If a T cell happens to also see MHC-II as the antigen as well, that's additive binding on top of the normal binding to MHC-II that all T cells have. So that T cell will naturally bind more tightly to the self-antigen, in which case it's likely to be deleted.