Just as the job of a garden fountain is to provide a consistent source of ‘rain’ onto a basin filled with water, the Milky also receives ’rain’ in the form of gas.
In the case of the garden fountain, a motor operates to suck water from the basin and to shoot it out a spout at the top. For galaxies like the Milky Way, it is the stars themselves that act as the motor.
In particular, the most massive stars produce significant winds which blow out of the disk of the galaxy. These massive stars also explode entirely, driving most of their material up and out of the galaxy disk. This gas is so hot it that it emits in X-rays, and it is also rich in metals, which for astronomers mean it contains elements heavier than hydrogen and helium.
This hot, metal-enriched gas blows straight out of the galaxy. If one imagines a galaxy like the Milky Way as a flat dinner plate, then the gas shoots straight out of the plate, both upwards and also downwards.
It then mills around up (and down) there for a while, cooling and mixing with the gas of other supernovae and winds of massive stars. Eventually, it cools down and ‘rains’ back down on the galaxy.
Note that as this gas is expelled from both sides of the galaxy, it also rains back down onto both sides of the galaxy. This concept is a bit less intuitive. Going back to the garden fountain analogy, it would be as if the fountain was suspended in the air.
In this case the ornamental top bit would have to be duplicated, turned upside down, and attached to the basin extending in the other direction (downward). The water would be sucked up from the basin both to the very top of the fountain and to the very bottom. This water would rain down into the basin in the usual way and rain up to the basin as well.
We call this the ‘galactic fountain’ model. Similarly, the gas in the Milky Way rains back down (and up) onto the galaxy. It carries with it the building blocks of new stars and planets, and thus provides an important recycling mechanism for galaxies. The Milky Way has already put into place a galaxy-wide recycling program!