Matter is a way of standing to contradictory forms, and contradictory forms can’t be in anything, so matter stands to what is outside of itself, demanding it be the finite part of some larger whole. This generalizes a point Cajetan makes in summarizing why ipsum esse cannot be in a genus, since genus (corresponding to matter) stands to differences extra se, but esse has no differences outside of itself (cf. comm. no. II, In Primam 3.5)
It’s thus the material of things makes them parts of larger wholes. In seeing the whole of spacetime, for example, we conceptualize the totality of termini of local motions. As Aristotle put it, we only come to know place from change of place. Newton was right that there is something formal and prior about spacetime, but not because there is absolute space or time – i.e. a mathematical ghost somehow behind the visible world – but because, given local motion, the totality of here-there stand to the magnitude of any locally movable substance like rational-irrational stand to animal or prime-composite stand to number.
When we speak of the immateriality of cognition, we mean that, by cognition, forms made distinct by matter now constitute a single whole, namely, the world. Contrary to the stock philosophical example, you don’t open your eyes and see a tree, you open your eyes and see a whole visible world, within which you might focus on a tree, the grass, the sky, the bird, etc. Any sense gives us this cognitive whole, for example, even if wood ticks only detect a few chemical scents of living bodies, those scents constitute an entire world of possible hosts. The tick sees me, the squirrel, the deer, etc as islands of habitation drifting through vast empty spaces.