Perfect pop music can come from anywhere and can go anywhere. They Might Be Giants have demonstrated this for a quarter century, ever since they started as a hyperkinetic duo, back in the mid-eighties, in Brooklyn. The band, which consisted of John Flansburgh (he supplied guitar) and John Linnell (he supplied accordion, sometimes saxophone), went the magpie route, drawing on a vast storehouse of influences: jittery New Wave pop, largely, but also classic rock, hip-hop, show tunes, advertising jingles, and novelty records. During their first decade as recording artists, they were a consistent source of pleasure: brainy but never bloodless, quirky but never desperate for attention. The duo expanded into a full band with the addition of regular backing musicians (currently the guitarist Dan Miller, the bassist Danny Weinkauf, and the drummer Marty Beller). They released an album every two years like clockwork. And slowly but surely, they wove their way into the pop-culture fabric, contributing the theme song to the sitcom “Malcolm in the Middle,” and also re-performing Bob Mould’s theme to “The Daily Show” when Jon Stewart took over for Craig Kilborn. And their best songs, from the unhinged “Put Your Hand Inside the Puppet Head” to the jittery, soaring “Birdhouse in Your Soul” to the almost sentimental “New York City,” were the equal of any pop music of the era.

As society turned toward the Internet, it seemed that They Might Be Giants would be natural beneficiaries. They had always embraced technology and the freedom it brought: their early Dial-a-Song, which put new material on their Brooklyn answering machine, was a legendary attempt to skirt the edges of traditional distribution channels, and they were the first band to release a download-only album (“Long Tall Weekend,” back in 1999). And they exemplified the triumph of the geek, as illustrated by the cult of Steve Jobs, “The Social Network,” “The Big Bang Theory,” and a thousand trend pieces. So the late nineties and the first part of the twentieth century should have offered them a perfect place to land. Instead, they receded somewhat. Why?

There are two theories, somewhat connected. The first is that social shifts camouflaged them: their practice of careering gleefully between pop-music styles and wryly written, surreal lyrics was rendered redundant by the broader culture. That spectator experience, or something like it, was always going on in the heads of listeners, to the point where they didn’t need They Might Be Giants to do it for them. The second, simpler explanation was career fatigue. The band had been together for fifteen years: a long time for any pop band, let alone one as dependent upon the ideas of freshness, sharpness, and surprise. The 2002 documentary “Gigantic: A Tale of Two Johns” made a strong case for the band’s supremacy in the genre, but also (maybe unwittingly) felt valedictory, in part because it was released along with “Dial-A-Song: 20 Years of They Might Be Giants,” a double-disc set of outtakes and rarities.

And then a strange thing happened: the band found the Fountain of Youth, almost literally. In 1999, they had recorded “No!,” a record that was billed as fun “for the entire family.” What that meant was that it was for children, but not quite: it was a consciously (and sometime self-consciously) childlike record, a strategically junior version of their other material. It had songs about robots. It had songs about respecting the wishes of others. It had “John Lee Supertaster,” a tall tale about a man with an enhanced sense of taste. It sounded like an expansion of their sound in such a way that their next adult record seemed like a contraction.

And then, in 2005, they went all-in for kids’ records with “Here Come the ABCs.” It was a critical and commercial success. The video went gold. The project launched the band on a second career as kid-friendly artists. The next album was the Grammy-winning “Here Come the 123s,” and after a half-hearted return to adult material (a live album and a somewhat sodden studio set produced by the Dust Brothers), they polished off the children’s trilogy with “Here Comes Science.” Of the three, it’s perhaps the strangest, and as a result the most representative. It’s also the only one that was subject to fact-checking. The band had covered “Why Does The Sun Shine?,” a science song from the nineteen-fifties that instructed children that “The sun is a mass / Of incandescent gas.” In the course of reviewing the album for actual truth—it’s a science album, after all—the band discovered that scientific knowledge had progressed significantly in the intervening half century. The solution? They added a second song called “Why Does The Sun Really Shine?,” which updates the lyric to reflect new information: “The sun is a miasma / Of incandescent plasma.”

The move toward children’s records paid dividends for both the band and its audience, which was composed largely of college kids of the late eighties who were grateful to have acceptably quirky children’s records to play to their pre-schoolers. At the same time, it pushed the band’s adult music even further into the background. A second career retrospective, “A User’s Guide To They Might Be Giants,” appeared in 2005, reinforcing the notion that the adult incarnation of They Might Be Giants might have given way to a second career. Even the ultimate geek placement, the theme song to “The Big Bang Theory,” went to another band, the Canadian clever-rock practitioners Barenaked Ladies. (Eh Might Be Giants?) A 2011 album titled “Join US” returned them to adult recording in uncharacteristically aggressive fashion: it was overstuffed with ideas, more exhausting than exhilarating, without the easy brilliance of their best records. Now they’ve released their sixteenth album, “Nanobots,” and it’s cheering to report that it’s a return to form.

The album opens with “You’re On Fire,” a relatively straightforward song about spontaneous combustion (or anger management) that rides along on power chords and surging backup vocals. “Nanobots,” the title song, plays like an advertising jingle for tiny, helpful robots. And “Black Ops” is a menacing, minimalist ode to spycraft. It’s a surprisingly strong opening stretch that the rest of the record sometimes matches: “Call You Mom” could be an NRBQ song were it not deeply strange, and “9 Secret Steps” is an enigma wrapped in Buddy Holly mannerisms. Robert Christgau once described a song as “XTC-does-Bo-Diddley,” which could be shorthand for any T.M.B.G. song, if you replace the names with different names. There are so many influences here that there are no influences but the band itself.

Formally, “Nanobots” returns the band to a strategy they employed on “Apollo 18,” back in 1992: of the twenty-five tracks, a third are alarmingly short, under a minute and as short as nine seconds. Clustered toward the middle of the record, these songs (the six-second “Hive Mind,” the nine-second “There,” the twelve-second “Tick”) function not as pieces of larger compositions but as autonomous pieces (nanosongs, perhaps?). They’re catchy, but their effect is to direct attention toward the longer, more substantial songs. “Sometimes a Lonely Way” is heartbreaking and straightforward (“not everyone you’ve abandoned is still standing by”), like the best Fountains of Wayne ballads. And “Tesla,” one of the band’s biographical sketches (“Meet James Ensor,” “James K. Polk”), compresses the life of one of the twentieth-century’s most important thinkers into two minutes and change with ambition, pathos, scientific specificity, and a lovely vocal performance. (In the recent documentary “The Story of the Eagles,” the band’s appeal is defined with a single inelegant phrase: “song power.” You could say the same for They Might Be Giants, who have now appeared inside the same parentheses as the Eagles for perhaps the first time in history.)