Short answer: No one knows.
To know how the elves managed to sense Sauron we have to understand how the One ring works. What follows is speculative, as we have no definite answer.
First, let's speak about Ósanwe. Ósanwe means "communication of thought" in quenya.Tolkien wrote a eight page essay about it named Ósanwe-kenta. Note that the narrator is not Tolkien but an elvish loremaster.
What is Ósanwe?
To be very simplistic about it, it's telepathy. It allows to send thoughts to another mind, and to read other minds.
This ability is available in theory to all men, elves, maiar and Vala.
In pratice, humans are very limited:
Men have the same faculty as the Quendi, but it is in itself weaker, and is weaker in operation owing to the strength of the hröa, over which most men have small control by the will.
The mightiest of Men, such as Denethor, can read minds at will. Sending thoughts is possible to the greatest of the elves:
Often after the hobbits were wrapped in sleep they [Celeborn, Galadriel, Gandalf, and Elrond] would sit together under the stars, recalling the ages that were gone and all their joys and labours in the world, or holding council, concerning the days to come. If any wanderer had chanced to pass, little would he have seen or heard, and it would have seemed to him only that he saw grey figures, carved in stone, memorials of forgotten things now lost in unpeopled lands. For they did not move or speak with mouth, looking from mind to mind; and only their shining eyes stirred and kindled as their thoughts went to and fro.
All communication was consensual, as any mind could choose to remain closed except from Eru.
The effort required for communication could be lessened by three factors, affinity, urgency, authority:
The Incarnates have by the nature of sáma the same faculties; but their perception is dimmed by the hröa, for their fëa is united to their hröa and its normal procedure is through the hröa, which is in itself part of Eä, without thought. The dimming is indeed double; for thought has to pass one mantle of hröa and penetrate another. For this reason in Incarnates transmission of thought requires strengthening to be effective. Strengthening can be by affinity, by urgency, or by authority.
Affinity may be due to kinship; for this may increase the likeness of hröa to hröa, and so of the concerns and modes of thought of the indwelling fëar, kinship is also normally accompanied by love and sympathy. Affinity may come simply from love and friendship, which is likeness or affinity of fëa to fëa.
Urgency is imparted by great need of the "sender" (as in joy, grief or fear); and if these things are in any degree shared by the "receiver" the thought is the clearer received. Authority may also lend force to the thought of one who has a duty towards another, or of any ruler who has a right to issue commands or to seek the truth for the good of others.
Morgoth's perversion of Ósanwe
Then Morgoth (and then Sauron) decided to pervert Ósanwe, and to implant his own thoughts in the mind of others. However, it still required consent:
In like manner, extortion of the secrets of a mind may seem to come from reading it by force in despite of its unwill, for the knowledge gained may at times appear to be as complete as any that could be obtained. Nonetheless it does not come from penetration of the barrier of unwill.
So how Morgoth did it?
He found that the open approach of a sáma of power and great force of will was felt by a lesser sáma as an immense pressure, accompanied by fear. To dominate by weight of power and fear was his delight; but in this case he found them unavailing: fear closed the door faster. Therefore he tried deceit and stealth.
Here he was aided by the simplicity of those unaware of evil, or not yet accustomed to beware of it. And for that reason it was said above that the distinction of openness and active will to entertain was of great importance. For he would come by stealth to a mind open and unwary, hoping to learn some part of its thought before it closed, and still more to implant in it his own thought, to deceive it and win it to his friendship.
Several objects were crafted to make the use of Ósanwe easier: the Palantiri, by Feanor.
The One Ring
What follows is speculation.
What was one the power of the Ring:
“he could see and govern the very thoughts of those that wore them [the lesser rings].
It's seems very probable that the One ring made Ósanwe far easier between ring bearers, giving Sauron a backdoor to control them.
However, consent is required. Always, by the will of Eru. Morgoth himself could not read the mind of a hobbit if he was unwilling.
So when Sauron put the Ring, all bearers had to consent (or at least no actively refuse him). Elves had a huge advantage, as they understood Ósanwe and had already practiced it. So they felt Sauron's presence in their mind, understood what it was and rejected him.