Wouldn’t a planet on course to collide with the earth be visibly moving toward earth at this point? It’s unlikely it would just appear out of nowhere.
Scientists have been surprised by asteroids before. They can't watch everything.
Besides, I could see them not telling anyone cause of the widespread panic it would cause over something no one can do anything about.