This is one of the simplest and most common figures of speech, a simile.
Similes make direct comparisons between two things, generally using the words "like" or "as," to make some characteristic of A more dramatically clear because it shares, in some way, that characteristic with B.
In your example from Wordsworth's poem, the "host of daffodils" is compared to the host of stars in the Milky Way: both present a vast, continuous view, and Wordsworth's daffodils benefit in our imagination by being compared to the multitudinous stars of the Milky Way. We can imagine that there must be a lot of them, in a great, continuous, "twinkling" mass!
Many of our most common expressions and cliches are similes—as white as snow, sing like a bird, as dumb as a post, and so on—but poets have a way of creating new and memorable similes that we often cherish:
Let us go then, you and I,
When the evening is spread out against the sky
Like a patient etherised upon a table . . .
("The Love Song of J. Alfred Prufrock," by T. S. Eliot)