It would be helpful for you to clarify your question. A retainer is usually an amount that the attorney deposits into the attorney's client trust account to be used to reimburse the attorney for out-of-pocket expenses and/or fees (depending on the nature of the fee agreement) as they accrue. A "retainer fee" can be a periodic payment by the client to keep the attorney available to the client whenever the client needs the attorney's services. Although heavily used in bygone days, this type of "retainer fee" seems to be used much less frequently these days (in my experience). Some attorneys, particularly in the criminal law arena, use what they refer to as a "non-refundable" retainer fee. The way in which the Bar Associations view non-refundable retainers can vary from State-to-State.
Let me nevertheless presume that your question relates to the way in which attorneys determine the amount of an initial deposit, to be applied to the attorney's out-of-pocket expenses and fees (if applicable under the fee agreement) as they accrue. Each attorney makes his/her own decision about the amount. What the attorney does not want to do is to let the client get in so deep with accrued and unpaid expenses that conflicts arise between attorney and client. This is a recipe for disaster for the attorney-client relationship. The best way to avoid those problems is to have a clear fee agreement, establish a sufficient trust account deposit, and provide the client with regular billing. In this situation in which the retainer is deposited into the attorney's client trust account, any surplus amounts beyond those necessary to pay the attorney's out-of-pocket expenses and fees, as provided int he retainer agreement, belong to the client and the attorney would be under an ethical obligation to refund the surplus to the client. This is not at all uncommon. I hope I've answered your question.
There are different kinds of retainers, but it generally reflects how much work the attorney thinks the case might take - a complex case would likely need a higher retainer. If the latter part of your question asks if you can get part of your retainer back, the answer is yes, if the case resolves (or you dismiss the attorney) before that money is spent, absolutely. Personally, I've refunded retainers in situations where I've managed to resolve a case in less time than I originally thought. It's not being "overcharged," it's a good thing, since the attorney was able to do the job quicker and easier than originally planned.
As others have previously stated, attorneys ask for retainers of various amounts depending on the client and the case. The primary reason an attorney will ask for a retainer is to make sure he/she is going to be paid for the work that is to be done. Typically the amount of the retainer will be based on the expected cost of attorney's fees and expenses throughout the case, though sometimes the retainer is set up to be replenished knowing that it will cost much more.
A retainer is different from a flat fee. A case that is taken on as a flat fee case is a negotiated price for the work. Certain cases like criminal cases or real estate closings are frequently done on a flat fee basis and in those situations you will not be refunded anything. In a retainer situation if the attorney completes the case more easily than expected or if you dismiss the attorney prior to its conclusion then you should expect to receive the remaining portion of your retainer back.
Retainers are also frequently negotiated. If you cannot afford the amount the attorney is asking for he/she may be willing to accept a lesser amount with the understanding that it will be replenished.