I don't know but perhaps I read that later schools (i.e. early schools but later than the Pali suttas) developed the doctrine of "store-house consciousness" -- ālāyavijñāna in Sanskrit -- as an answer to this question (i.e. to explain the phenomenon):
... and finally the fundamental store-house consciousness (ālāyavijñāna), which is the basis of the other seven. This eighth consciousness is said to store the impressions (vāsanāḥ) of previous experiences, which form the seeds (bīja) of future karma in this life and in the next after rebirth.
Something like that has been mentioned a few times on this site: Posts containing 'alaya'
One of the comments to this question claimed that Buddhism is "exclusively an idealistic philosophy, and not materialistic at all" -- in any case I don't know how to understand "store-house consciousness" and whether it is or was seen as a physical/material "medium" (which your question was asking about).
I think the first five consciousnesses are involved in physicality, that the last three consciousness instead have the "mind" as their "cognitive sensor" -- the Wikipedia article translates the eighth as simply "memory", which perhaps isn't assumed to be entirely associated with one body or one person.
There's a book The Buddhist Unconscious: The Alaya-vijñana in the context of Indian Buddhist Thought. Skimming through it, I think it says that the Abhidhamma originally describes mental processes as being a series of moments (thought-moments), and as such it wasn't good at explaining how or what chains those moments together -- and it was for that purpose, i.e. to explain (or "model") that, for which one or two additional types of consciousness (translated as e.g. "memory") were added to Abhidhammic doctrine:
The text is claiming,
in other words, that neither samsara nor Nirvana are explicable without the
continuity of mind the alaya-vijñana epitomizes – explicating, in effect, the
opening verse in MSg I.1:
“As this [alaya-vijñana] exists, so do all the destinies
as well as the realization of Nirvana.”
And then
Karma, rebirth, and the alaya-vijñana
The sections called the action defilements (karma-sadkleka) (MSg I.33) and the
birth defilements (janma-sadkleka) (MSg I.34–42) largely focus upon the
processes of rebirth. These were conceptually problematic because the series of
material dharmas is completely severed during these periods of transition from
one lifetime to the next. The text addresses both such junctures within the traditional three-lifetime interpretation of the formula of dependent arising: those
which occur between the karmic formations (sadskara) and vijñana, and
between appropriation (upadana) and existence (bhava). Since vijñana was the
only factor explicitly stated, in both the early Pali and Abhidharma traditions,
to continue from one lifetime to the next, the continuities of all the factors that
must “last as long as samsara” would have to persist in some kind of relationship
with this ongoing stream of vijñana – at least at these crucial disjunctions. This
much was shared by the various Abhidharma schools, though their explanations
of the exact processes involved varied considerably.
MSg I.33, for its part, argues that this form of vijñana must be the
alaya-vijñana:
I.33. For what reason would the defilements consisting of action (karmasadkleka) be impossible [if there were no alaya-vijñana]? Because there
would be no consciousness conditioned by the sadskaras (sadskarapratyayam vijñanam). Without that [alaya-vijñana], existence (bhava)
conditioned by appropriation (upadana) would also be impossible.
(MSg I.33)
(The "MSg" being cited is the Mahayana-sadgraha)
I think that's saying there's rebirth from one moment to the next within a person's life, then at a death the rebirth from one person to another.
I think previous questions on this site have been answered along the lines of, just that there isn't a law of nature which says that consciousness is bound to a specific body -- that saying so would be a materialist view.