Why do editors sometimes reject manuscripts for being out of scope even though they cite references from the same journal?
Cape Code has given a good answer, but it's not the only possibility for such a rejection.  Suppose you publish a paper in, say, "Topology and Its Applications", in which you prove some topological result using (among other things) a set-theoretic lemma. And suppose I later prove some result in algebra using (among other things) your lemma.  Of course, I would cite your paper, but that doesn't put my algebra paper into the scope of "Topology and Its Applications".