Because that news is a total game-changer, and of such magnitude that no one would keep it secret.
If he shares it with others, what happens to Jon, who is still completely in the dark? He's a Targaryen with the rightful claim to the Iron Throne. They were talking about resentment in the north towards that family and towards Daenerys and how someone might want to take her out because of it. That could very well translate to the same feelings about Jon (who also let wildlings past the Wall). If word gets out and there are spies anywhere, then Cersei knows there's someone with in irrefutable claim that trumps hers, and either assassins or direct attack might come.
In either case, Jon would be completely blind-sided.
There's also considerations of that news fracturing their family unity, with Bran and Sansa now holding the exclusive legitimate Stark succession rights (which they already had, but the lords and Sansa were all willing to align behind Jon because "Ned Stark's blood runs in his veins" - or so they thought). There's considerations of fracturing the Northern and Vale alliance - Jon bent the knee, as King of the North, committing the North, but if people find out he's actually Targaryen, then what he did was pledge the North to himself as the King of the North - a title he gained under, it would be viewed, as suspect circumstances (did he know before?, they might ask).
Finally, Jon has to decide what he wants to do with this information. Is he going to try and claim the Iron Throne for himself? Will he denounce that claim and defer to Daenerys? Will he make an announcement while giving up his claim as King of the North? Anything he wants to do, if he wants to keep things in place to fight the Night King and, eventually Cersei, will have to be considered and thought out. If Bran blabs that to anyone, it's basically blabbing it to everyone. Jon can't plan or think out his options, because the ball will already be in motion, but without any kind of control from Jon.
Basically, if Bran told anyone else but Jon's closest friend who has no motives that would be impacted, except to support Jon (answers "Why Sam?" - even Sansa and Arya are impacted as members of the Stark family), he'd be acting like a major jerk. Jon has to know, first, and then he has to decide what to do with that.