According to Fidelity Investments, one of the largest platforms for retirement plans, there are nearly 400,000 retirement accounts worth at least $1 million. That number is up 40% over last year.

It's a testament to the wealth-building power of investing in the stock market and keeping a long-term mindset, letting compounding do the heavy lifting. But becoming a millionaire isn't a coincidence. It takes a methodical approach and a specialized account, such as an individual retirement account (IRA).

Here are the secrets the wealthy use to build the type of nest egg that can make your golden years shine.

1. They don't procrastinate

Retirement feels so far away... that is, until it's upon you. Our minds are wired to think about the here and now, which makes focusing on retirement planning such an easy thing to put off. Don't fall into that trap.

Your money works harder for you the more time you give it. If you invested $1,000 monthly at a 10% annualized return, it would take 23 years to amass $1 million.

Suppose you're already 50 and want to cut that to 15 years. You're going to need to invest $2,500 monthly. That's $450,000 in principal versus $276,000.

Considering you can only contribute $7,000 annually to an IRA ($8,000 if you're 50 or older), you are penalized even more because you can't get those annual contribution allowances back once they pass.

2. They know how to play the tax game

There are multiple types of IRAs. The two most common plans are traditional IRAs and Roth IRAs. The two have some crucial differences, especially in taxation.

A traditional IRA is tax-deferred, meaning you don't pay taxes until you withdraw funds in retirement. The benefit is that you could lower your taxable income in all your contributing years.

A Roth IRA is the opposite. You pay taxes on your contributions, but your withdrawals are tax-free later, assuming you have followed all the rules.

Planning and choosing your account based on your finances is essential. Someone retiring at a lower tax bracket in retirement may want a traditional IRA to save on taxes during their high-earnings years. Someone planning to pay more taxes during retirement might choose a Roth IRA.

Don't hesitate to consult professionals for advice on the best option for your situation.

3. They swing for singles and doubles, not for home runs

Managing risk is essential because you can only add so much to an account annually. Warren Buffett has said that rule No. 1 is not to lose money. Rule No. 2? Don't forget rule No. 1. It can be tempting to swing for the fences with risky stocks, especially in a Roth IRA where your gains aren't taxed.

But what if you make a big mistake and your account loses a lot? That's potentially years of gains and contributions you can't easily make up. So, look for the easy score instead of trying to swing for the fences.

That entails index and exchange-traded funds or blue chip stocks with a low risk of going out of business. Diversify your investments and take a long-term approach, which is the goal of investing in an IRA in the first place. You'll likely wind up far wealthier if you stay consistent over 10, 20, or 30 years than if you tried to find the next big thing with your precious IRA funds.