Your premise is false. It is not the case that "almost all anime series have a 'going to the beach episode'".
The gist of the argument below is as follows: most non-short TV anime of reasonable length (1 or a few cours) do not have beach episodes. However, very long anime will often have beach episodes simply by virtue of being long. OVAs may also incorporate beach episodes, but not so frequently that it would make sense to say "almost all".
If it seems like every show has a beach episode, that's because you preferentially watch the kinds of shows that tend to include beach episodes, and says more about your tastes than it does about anime.
Let's look at some one-cour shows
For an illustrative example, let's just look at the full-length one-cour anime from Summer 2014 that I watched in their entirety. Those that do contain a "going to the beach episode" have their titles bolded.
- Free! Eternal Summer. Despite this being an anime about swimming set near a seashore, the longest segment on a beach is few minutes in length, and is not the fan-servicey type of thing you're talking about (other than the show having lots of half-naked men in general).
- Gekkan Shoujo Nozaki-kun
- Sabagebu!. I don't remember any beach segments in this one, but I could be wrong.
- Tokyo ESP. There is a fairly long segment where one character happens to be on a beach, but this still isn't a "beach episode" in the sense you're talking about.
- Fate/kaleid liner Prisma Illya 2wei. They do talk about going to the beach, but they never actually go there.
- Futsuu no Joshikousei ga Locodol Yatte mita
- Rokujouma no Shinryakusha!
So that's 1/9. Certainly not "almost all". But there are systematic biases in the things I included in that sample, so let's examine those.
For one, I probably have an inclination not to watch shows that have beach episodes. There were 29 one-cour full-length anime in Summer 2014, and if it were the case that all the other 20 had a beach episode, then the figure would come out to 21/29, which is sort of "almost all" - but a cursory examination of episode synopses for the other shows suggests the following breakdown. I welcome corrections.
- Definitely a beach episode: Rail Wars; Majimoji Rurumo; Persona 4 The Golden Animation
- Maybe a beach episode: Bakumatsu Rock; Shounen Hollywood; Barakamon; Jinsei; Momo Kyun Sword; Seireitsukai no Blade Dance
- No beach episode: Tokyo Ghoul; Sengoku Basara Judge End; Space Dandy 2; DRAMAtical Murder; Ao Haru Ride; Hanayamata; Re:Hamatora; Love Stage; Kuroshitsuji: Book of Circus; Nobunaga Concerto
So it looks like we have between 3 and 9 of these with beach episodes; let's assume that all the ones where I was uncertain do indeed have beach episodes, so that we have a total of 10/29. That's certainly not "almost all".
But what about longer shows?
But what about shows that are longer than one cour? What if those shows are more likely to have beach episodes? Well, they probably are. The longer a show gets, the greater the odds that it's going to spend an episode sending its characters to a beach. After all, there's only so many different settings you can use for your episodes. For things that run particularly long, there may even be multiple beach episodes! I would definitely be surprised if a show with more than 100 episodes or so didn't have a beach episode.
But I don't think there's anything special about beach episodes here - any show that runs sufficiently long is also likely to have an episode where the characters partake of some other anime staple like going to the hot springs or playing a game of baseball or participating in a school cultural festival, or whatnot.
And keep in mind, these long-running shows only make up a small fraction of anime (in terms of number of shows, not total amount of footage).
And what of OVAs?
And what about OVAs? What if the reason that the TV series don't have a beach episode is because the beach episode is shunted off to an OVA? This argument also has merit. Let's look at the numbers: which of the OVAs released during Summer 2014 contain at least one episode (20 minutes) worth of beach? For a list of OVAs, I consulted Anichart for Summer 2014, and only included OVAs of at least half-length (10 minutes or more) that were associated with a TV series. Only those that have a beach episode are listed below.
- Definitely a beach episode: zilch.
- Maybe a beach episode: Hayate no Gotoku OVAs
- No beach episode: Tamayura S2 OVA; ImoCho OVA; Girls Und Panzer OVA; Non Non Biyori OVA; Ano Natsu OVA; Kill la Kill OVA; Chuu2 S2 OVA; Suisei no Gargantia OVA; D-Frag OVA
Nope. Beach episodes in OVAs certainly do exist, but they aren't all that common, and I'd be surprised to find any season in which beach-episode OVAs made up the majority.
It's possible that Summer 2014 is non-representative for some reason, but I can't be arsed to spend time gathering more data from other seasons. I've seen my fair share of anime and am pretty sure the conclusions I draw above are correct.
We have also ignored shows that aren't full-length (such as 4-minute shorts). I don't think this is much of an issue, since that's precisely the kind of show people typically talk about when they talk about anime.