So, a little backstory. I've never been a strong swimmer. A couple of lessons as a kid. Then I joined the Navy, and my first swim test in ROTC I flunked. I took a class in college that got me proficient enough to pass.
But I've never been a strong/ comfortable swimmer, didn't snorkel on my honeymoon, etc.
When I was 40, I had a miscarriage. Shortly after, I gave in to the suggestion from a friend (she'd been working on me for a few years) to try my hand at a triathlon (I was already running). There was a team called Moms in Motion (they are across country, now, and there's a similar one called Momentum for Life). It was a sprint tri, and I warned her that I couldn't swim. She was the swim coach for the moms in motion team (no, you do not have to be a mom).
Anyway, the team fee was not cheap. $250, and the training went from June through mid-Sept. Plus I had to get gear. BUT, it started in the pool (local HS pool), also included a few weeks of once/ week at a health club, and eventually moved into the ocean, yikes! I did the tri 2 years in a row, and slow as molasses, and the ocean still freaks me out (last time I did it was 2011).
HOWEVER, now I can swim. I generally try to swim 2x a week at the YMCA, 1500 yds at a time.
How to do it cheaply is going to depend, completely, on where you live. Where I live, we have a couple of public pools that you pay a membership for (get a punch card to swim, at about $5-10 per swim). There are health clubs with pools, including 24 hour fitness, the YMCA, and some really expensive country clubs and fitness clubs. Most of these places have swim lessons. There are also smaller places in town (people with backyard pools) that will teach you to swim.
None of these are really cheap. The YMCA is the cheapest (approx $5-10 per 30 minute class for a group class for kids), but you get what you pay for. For my toddler's class, the more expensive class is much much better. So, consider that quality can vary a LOT.
The next is practice. Do you already have access to a pool? (Like at your gym). That is very important. Once I learned to swim, I eventually joined the Y because my other gym's pools had 2 lanes and was only 12 yds long. Do you have any friends who swim? They may be able to help you out.
Otherwise, I have the book Total Immersion, which has been helpful to me on form. A little bit. Note, I'm still slow as molasses. I've managed to increase my speed such that it *only* takes me 42 minutes to swim 1500 yds. But I am comfortable in the water, in a lake, and in the ocean if the waves aren't huge.
In short, look at:
YMCAs
Swim clubs
Private pools
Private lessons
University classes
High schools (during the summer)
City/ county classes
Places that may teach scuba
Friends
ETA:
YMCA lessons were about $10 per 25 minutes for my 8 year old
My toddler lessons are $200 for a 9 week session, 30 minute lessons - $22 per half hour
Private lessons down the street were $30 per half hour