It wasn't a sudden change of mind. The Borg demanded the technology without guaranteeing safe passage before finally relenting. Also, the Queen and the Collective are indistinguishable.
Here is the exact dialogue from the episode "Scorpion":
JANEWAY: Open a channel.
BORG: We are the Borg. You will be assimilated. Resistance is futile.
TUVOK: They've locked onto us with a tractor beam.
JANEWAY: Borg vessel, this is Captain Janeway of the starship Voyager. I have tactical information about Species 8472. I want to negotiate.
BORG: Negotiation is irrelevant. You will be assimilated.
JANEWAY: Borg vessel. What you're receiving is a sample of the knowledge we possess. If you don't disengage your tractor beam immediately, I will have that data destroyed. You have ten seconds to comply. We know you're in danger of being defeated. you can't afford to risk losing this information. Disengage your tractor
(Janeway is beamed away.)
BORG: State your demands.
JANEWAY: I want safe passage through your space. Once my ship is beyond Borg territory, I'll give you our research.
BORG [OC]: Unacceptable. Our space is vast. Your passage would require too much time. We need the technology now.
JANEWAY: If I give it to you now, you'll assimilate us.
BORG: Species 8472 must be stopped. Our survival is your survival. Give us the technology.
JANEWAY: No. Safe passage first or no deal.
From this, I would not describe it as a "sudden change" of mind on the Borg's part. Janeway knew she would be able to negotiate with the Borg because she had something they desperately needed. Even then, the Borg tried to "have their cake and eat it too" by demanding the technology without guaranteeing safe passage, but Janeway refused and the Borg relented.
As for the Queen, recall from First Contact that she and the Collective cannot be distinguished. She is simply an avatar for the entire Collective.
BORG QUEEN: I am the beginning. The end. The one who is many. I am the Borg.
Her decisions and influence cannot be thought of as separate from those of the Collective.