I do think you should max out the tax effective alternatives before investing after tax cash.
It's not really that simple.
There are many reasons not to do this. To fully understand the situation as it applies to you you need to either talk to a tax professional or educate yourself in the applicable tax laws and run a bunch of scenerios.
First, as you state, yes, the money you put in is pre-tax. However, when you withdraw it it
is taxed, and taxed as ordinary income. Let's explore the consequences of this.
If I currently mow lawns for a living while going to school for my MBA, I am currently in a very low tax bracket, but will eventually be in a very high tax bracket. I can expect to pay a higher tax rate in the future. Why should I avoid a low tax rate now to pay a high tax rate in the future (when I retire)?
If I am currently in a high tax bracket, but plan to retire to a small community and live simply, then my retirement tax rate will be lower. I almost certainly should strive to lower my taxes by avoiding my current high rates in exchange for future low rates.
However, 401K withdrawals are taxed as ordinary income. My stock purchases are taxed at the capital gains tax, currently 15%. If my ordinary income taxes exceed 15%, I end up paying more taxes from the 401K.
Certainly if your employer offers a matching rate you should contribute enough to get that match. Taxes be damned, that's free money! beyond that, the tax issue is complicated.
Then, you also don't get to claim a tax loss if a stock you buy tanks.
401K plans are usually restricted. My company has a collection of ho-hum mutual funds, some charging an egregious 5.75% front load, others charging up to 2.44% for fees.
Note my assumptions assume that you are buying stocks and holding for years. A lot of people don't have that discipline. Taking a tax haircut every few years, or months, is a good way to reduce your savings. In a 401K you can buy and sell without tax consequences (until you remove the money).
There is also an advantage to getting more money into the market sooner. Since you are investing pretax, you are getting more money into the market sooner, and this really adds up when compound interest is taken into account.
There is the disadvantage that if your 401K contribution drops you down a tax bracket, you are penalized in the form of tax breaks you get from things like morgages.
There are other issues: while you
should only be putting money in a 401K that is intended for retirement, and you should have a 6 month cash cushion, emergencies happen to the best of us. Your mother's house is destroyed by Katrina. Your husband develops cancer, and you hit your insurance limit. Etc. Dipping into a 401K entails a signficant penalty you would not face if the money was invested in other ways. What risk/reward valuation do you put on this?
Here is a
good article covering some of these issues.
ETA: I think the reason you see this advice (max out 401k) from professionals even is the assumption that the average person cannot manage their own investments. Data based on analysis of individual brokerage accounts bear this out - the average person substantially underperforms the market. But, there are now instruments to help you out. Vanguard has a bunch of index funds and funds that adjust based bond/stock holdings based on when you want the money. Basically the idea is buy and hold. Just buy an index. For example. SPY is the symbol for in index that tracks the S&P 500. The S&P 500 runs 8-10% returns over long periods of time. So, if that is what you want, just buy SPY every paycheck. Don't try to guess whether the market is going up or down, never, ever sell it, just accumulate until you retire. Then, you will only pay the tax haircut once. If that seems too hard, and your 401k program is good, then maxing out the 401k may be the best bet, even if it is not the most tax efficient solution for your situation.