That doesn't happen in the book
The scene where Sauron immediately 'finds' Frodo when he puts the ring on in Bree exists only in the films; but while it's an invention, it's a good way to visually express a broader idea, that the Ring does not grant invisibility against the more powerful servants of Sauron.
The Nazgûl, which are the principle threat at the time, do not perceive the everyday world very clearly:
'Can the Riders see?' asked Merry. 'I mean, they seem usually to have used their noses rather than their eyes, smelling for us, if smelling is the right word, at least in daylight. But you made us lie down flat when you saw them down below; and now you talk of being seen, if we move.'
'I was too careless on the hill-top,' answered Strider. 'I was very anxious to find some sign of Gandalf; but it was a mistake for three of us to go up and stand there so long. For the black horses can see, and the Riders can use men and other creatures as spies, as we found at Bree. They themselves do not see the world of light as we do, but our shapes cast shadows in their minds, which only the noon sun destroyed; and in the dark they perceive many signs and forms that are hidden from us: they they are to be most feared. And at all times they smell the blood of living things, desiring and hating it. Senses, too, there are other than sight or smell. We can feel their presence — it troubled our hearts, as soon as we came here, and before we saw them; they feel ours more keenly. Also,' he added, and his voice sank to a whisper, 'the Ring draws them."
Later, we see the behaviour of the Nazgûl, both before and after Frodo puts on the ring.
Over the lip of the little dell, on the side away from the hill, they felt, rather than saw, a shadow rise, one shadow or more than one. They strained their eyes, and the shadows seemed to grow. Soon there could be no doubt: three or four tall black figures were standing there on the slope, looking down on them. So black were they that they seemed like black holes in the deep shade behind them. Frodo thought that he heard a faint hiss as of venomous breath and felt a thin piercing chill. Then the shapes slowly advanced.
Immediately [upon putting the Ring on], though everything else remained as before, dim and dark, the shapes became terribly clear. He was able to see beneath their black wrappings. [...] the third was taller than the others: his hair was long and gleaming and on his helm was a crown. In one hand he held a long sword, and in the other a knife; both the knife and the hand that held it glowed with pale light. He sprang forward and bore down on Frodo.
Each time the Nazgûl come close to Frodo, he feels the desperate urge to put on the ring. And we see here what happens when he does — he immediately stands out to them, glowing like a beacon, and they go from slow, careful advance to leaping forward to strike him and seize the Ring.
So this is what the filmmakers were trying to convey — that putting on the Ring did not hide one from the servants of Sauron, it in fact made you more visible to them, but they still had to be nearby to actually grab you.
In the film's universe, this is why it happened
In the internal logic of the film, though, there are probably several combined reasons for why that happened in Bree but did not happen when Bilbo wore the ring.
First, when Bilbo kept the ring, Sauron had no idea where it was. When Bilbo last used it, at his Birthday Party, Sauron had not yet captured Gollum, and did not know that the Ring had been found — he thought it still in Anduin or rolled down to the sea. His eye was not yet turned toward the Shire.
Second, once Sauron was aware and looking for the Ring in the Shire, searching from afar, Frodo never put the ring on. In the film, the Prancing Pony was the first time he put the ring on (on screen).
Third, the Nazgûl were there, in and around Bree, hunting for the ring. They are mindless puppets, slave to their master's will, and at the same time an extension of that will; they were so close that Sauron's presence was stronger than it usually would be.