Do you mean that IF I get an agent and IF I get the first in a series published, they still might decide not to release the rest of the series?
Yes.
You
may get a contract for more than one book, but it'll likely be for a set number (2 or 3 is not uncommon). Even then, though, a good contract will have an "out" clause (for both of you).
It all depends on the publisher's initial sales expectations, and how reality compares.
One thing someone outside the industry observed to me is that for writers, the work is often deeply personal, and its acceptance (or otherwise) can become intertwined with our self-image. For a publisher, though, it's a product they're selling, no more. This doesn't mean the people at the publisher aren't terrific folks who genuinely love books. It does mean if the numbers aren't there, they can't help you much, no matter how they personally feel about your work.
It's freelance. One contract at a time. And previous commercial performance will affect future contracts.