DATA: Computer, identify please.
COMPUTER: Sensors indicate low-level rf waves.
DATA: Is there a pattern?
COMPUTER: Affirmative.
DATA: Naturally occurring?
COMPUTER: Negative.
DATA: Key universal translator, please.
COMPUTER: Unable to comply. Weak signal.
DATA: Lock on comm. link and boost.
COMPUTER: Lock on complete.
DATA: Read, please.
COMPUTER: Insufficient signal strength.
DATA: Enhance, please.
SARJENKA [OC]: Is anybody out there?
DATA: Yes.
Star Trek: The Next Generation S02E15: "Pen Pals"
Above is all the dialogue we hear in the main scene you're asking about, with the specific line you're asking about highlighted in bold. Note that Data specifically turned on the Universal Translator (UT) about halfway through the scene, so it's safe to say that it was attempting to translate Sarjenka's language for the remainder of the scene.
It couldn't translate the incoming message immediately because the signal was too weak, but Data told the computer to enhance the signal, and four seconds later we heard the words "Is anybody out there?" come through the Enterprise's comms system in English.
So the real conundrum your question raises isn't really how Data understood the message, but rather, how was the UT able to accurately translate such a short message, from a species Starfleet had no previous contact with.
And the honest answer to that is we don't know, because the UT is a fictional piece of technology whose workings are only somewhat vaguely explained. For what it's worth though, here's what the Star Trek: The Next Generation Technical Manual has to say about it:
DERIVING A TRANSLATION MATRIX
The first step in deriving a translation matrix is to obtain as large a sample as possible of the unknown communication. Wherever possible, this sample should include examples of at least two native speakers conversing with each other. Extensive pattern analysis yields estimates on symbology, syntax, usage patterns, vocabulary, and cultural factors. Given an adequate sample, it is usually possible to derive a highly simplified language subset in only a few minutes, although Federation policy generally requires a much more extensive analysis before diplomatic usage of the Universal Translator is permitted.
In the case where the individual lifeform communicated with has a similar language translation technology, it is sometimes useful to translate outgoing messages into the Linguacode language form, since this is specifically designed as a culturally neutral "antiencrypted" language medium.
LIMITATIONS
The accuracy and applicability of the translation matrix is only as good as the language sample on which the matrix is based. A limited sample will generally permit a basic exchange of concepts, but can lead to highly distorted translations when concepts, vocabulary, or usage vary too far from the sample. Since the Universal Translator constantly updates the translation matrix during the course of usage, it is often useful to allow the program to accumulate a larger linguistic sample by exchanging simple subjects before proceeding to the discussion of more complex or sensitive subjects.
So the Technical Manual suggests that the UT normally requires a larger sample of a new alien language than it likely received in this episode, in order to derive a viable translation matrix.
That said, the writers are naturally free to bend the rules with things like that, based on the needs of the plot. And if we wish to make sense of this particular scene, there are a few assumptions we could make that'd allow us to view this as a less severe violation of the rules than it otherwise would be.
For example, while the episode suggests that the UT's initial translation of Sarjenka's words successfully interpreted the jist of what she was trying to say, couldn't it have been a rough translation, rather than a perfect one? I don't see any reason why not.
I also don't see any confirmation that Data's initial response of "Yes" was understood by Sarjenka. Data later told Picard that he'd been communicating with Sarjenka over the past eight weeks, but that doesn't prove she understood the very first word/s he spoke to her. Perhaps it took a few minutes for them to be able to have a working conversation.
Thirdly, note that the Technical Manual states that the UT uses things like syntax to derive a translation matrix, rather than brainwaves. Although Memory Alpha mentions brainwaves being a factor in the workings of the UT, I don't recall that being stated in any episode, whereas syntax definitely has been mentioned as a factor in canon (see the quote below).
Fourthly, it's been indicated that the more dissimilar the syntax and grammatical structure of a new language is to the ones in Starfleet's existing database, the longer it takes the UT to derive a translation matrix.
SISKO: Something must be wrong with the Universal Translator. Chief?
O'BRIEN: It's working, Commander, but for some reason it's having a hard analyzing their language patterns. Their syntax and their grammatical structure must be completely unlike anything in our database.
SISKO: We'll have to keep them talking until the computer can establish a translation matrix.
Star Trek: Deep Space Nine S02E10: "Sanctuary"
It follows from this that the more similar the syntax and grammatical structure of a new language is to the ones in the database, the more quickly the UT can translate it. Perhaps Sarjenka's language happened to have similar syntax to one or more languages already known to Starfleet, making it relatively easy to translate.
And that's not necessarily as extreme a coincidence as you might think. The TNG episode "The Chase" established that an ancient humanoid race seeded many worlds with its DNA, meaning that many humanoid races within Star Trek are distant relatives. Sarjenka's species could be one of these races; she was certainly humanoid, and mammalian in appearance.
The TOS episode "Bread and Circuses" also introduced Hodgkin's Law of Parallel Planetary Development, which was cited to explain how the people of planet 892-IV came to speak English, and live within a culture very similar to that of Ancient Rome, completely independent of any contact with Earth.
FLAVIUS [OC]: Don't move! Hands in the air!
SPOCK: Complete Earth parallel. The language here is English.
[...]
FLAVIUS: Are you trying to be funny?
SPOCK: Never. Colloquial twentieth-century English. An amazing parallel.
Star Trek: The Original Series S02E14: "Bread and Circuses"
If two species can develop the English language independent of one another, then it's not that much of a stretch by comparison to think that two species could independently develop languages that merely happen to have similar syntax.