In the past (before the pandemic, of course), when riding commercial jets, I noticed that sometimes, the pilots would bank to port, then to starboard, and repeat that multiple times, while climbing after takeoff. I was wondering if there was a reason they did that. Maybe they were just turning? Then why bank back to the other side? Perhaps they did it because there's nothing illegal with banking while you're climbing? But that might generate lift in a direction not quite perpendicular to the horizontal plane. I'd think that they would do it for a reason. Perhaps no one is sure of what I'm talking about. Any help?
When a commercial airliner takes off, they are vectored (directed) by ATC along or to a certain course. Or, they are given a specific published, codified procedure to follow. This provides the aircraft proper obstacle and traffic avoidance and clearance. It might also provide for avoiding sensitive areas like restricted airspace, environmentally and noise sensitive areas. You can view published procedures for your airport on Sky Vector
When ATC or the published procedure requires the aircraft to change direction, the aircraft has to bank to turn. When an airliner turns, they typically bank no more than 30° unless there is an emergency. The 45° bank you mentioned would be avoided due to discomfort for most passengers. Bank angle exponentially increases G-load. A 45° bank would increase G-loads by almost 50%. And some passengers would get the sensation that the wings were pointing perpendicular to the ground.
S-turns (one turn immediately followed by another turn in the opposite direction), while not illegal, are not normal in an airliner. And, it would not make sense to do them on takeoff nor climb-out.
I would suggest that you were suffering from a vestibular illusion called Somatogyral Illusions. A mild form of this is usually termed “The Leans”. A more severe form of this is termed “Graveyard Spins” and “Graveyard Spirals”. You can combat and overcome this illusion by sitting with your head straight up and as still as possible. Abrupt head movements will greatly aggravate this condition. Being able to see the horizon out of the front windowsheild also helps. Unfortunately, you do not have this view.