Look we should be honest here, as we are NOT Michael Phelps. Even Phelps has a completely different regimen now.
However we can look into what went into that style of consumption, or even my own which I sort of modeled after his. Swimming is a very intensive exercise, and it takes a lot of energy to do. You therefore need to consume said energy properly to do it well.
Why + Philosophy:
I want you to think about why do we eat? Even now I discussed with my roommate prior to writing this about what to eat for our upcoming lunch. What fuel is going to be necessary is what went through my head, and so I told him let's do potatoes and eggs. Get some carbs and some protein for the day ahead.
That was my reasoning, and when I eat (even when I go out); The process of deciding what to eat goes through a filter in my head. That filter is my why, and that is to become stronger.
For you it may be the same mentality, and for others it could be to lose excess fat. Your reasoning for why you eat should be at the forefront, and in this case we are talking about swimming. In this example swimming is our why.
How + Physics:
Now energy in goes to energy out, and if you are trying to swim multiple laps (especially when you're not used to it or adapted). You are going to need a lot of energy, especially at first, in order to even do that action.
Meaning you'll need some protein, some calories, and let's not forget minerals + water to stay hydrated!
I do not want to understate just how much that is an oversimplification, but for some people it could be news to them. All the more reason to include it!
AFTER your workout, this goes for dry workouts too, then you will need to consume protein in order to recover. It is used for energy alongside your caloric intake, but it is very crucial IMPERATIVE even to build muscle.
Yes, men and women alike need to do it. It isn't just for one particular gender, as everyone needs to approach it in that mindset. Just adjust for the size of the person really. Women tend to be more lean, and men tend to have slightly higher strength. Trans people in the middle, are just that, in the middle of the road.
My point is that you need to view as a calculation, as numbers and facts, and not sentimentality. Which often how people look at food, they look at it through the lens of how it makes them feel. That truly isn't important, at least not here.
What + Psychology:
This goes into the aforementioned mindset, as not only is it important to think about what you eat. It is also important to think about WHEN you eat, which is why I shared that post earlier.
You don't get cramps if you eat before swimming, that is just a myth. If you're sensitive then maybe, but most people won't. You need to carb load a bit before exerting so much. I ended up burning off so much of my hard earned muscle when I taught aquatic fitness regularly. It was actually VERY detrimental to my own progression, but I loved teaching my people so I did it anyways.
Although my mentality on food then had to change, and that lead to me having to eat close to 4000 calories a day. My psychology was that of a body builder, and so if the average person eats 1500-2000 calories. If you want to gain weight/mass as an average person, then you increase it to about 3000. Rough numbers don't focus on that!
For me I needed to do that, but also take into account the 5-13 aquatics fitness classes, personal training hours, 5-10 swim lesson hours, and my own workouts as well. I ended up exercising well over 25 hours a week. Meaning the caloric intake I needed to sustain that model, especially as a young lad, that was close to around 4000 calories!
My point in all of this is to get you thinking about when to eat, what to eat, and more. Some great examples of stuff to consume are bananas for their potassium, broccoli/spinach/nuts for their protein and complex nutrients, whey protein isolate after your workout if you REALLY need the mass. I often drank chocolate milk, but that was a sheer amount of sugar. Lead to some problems down the line.
In addition, they often tell swim competitors to grab a jar of peanut butter, and just take a spoon to it until you're done. Constantly fueling up over time.
That is the mentality you should somewhat adopt if you are to take swimming seriously. Even for the average person, there needs to be some adaptation involved.
This is advice for people to level up their swimming, or perhaps get started in the first place. While you swim you should make sure you are doing so in a public facility with a lifeguard on duty for safety.