The military is desperate for recruits, and they don't let go easily of the ones they get. If you decide you made a mistake as soon as you walk out of the recruiter's office, you can almost certainly get out of your contract. Once you get to basic training, however, things get harder.
Get a delayed admission program discharge. When you sign up for military duty, the recruiter sets a date for you to go off to basic training. Current policy dictates that If you apply for a discharge before you actually ship off, the military will grant it. This is by far the easiest way to get out of the military.
Get a medical discharge. Any severe injury which you have little chance of fully recovering from and which prohibits you from carrying out your duties will do. Go to a military doctor and have him evaluate your injury.
Claim conscientious objector status. It is not enough to suddenly come to your senses and decide that killing people is wrong under any circumstances. You will need to prove that you had a moral or religious awakening that now governs your life and prohibits you from killing others.
Claim to be gay or bisexual. Under the "don't ask, don't tell" law, expressing attraction to the same sex or engaging in "homosexual acts" is grounds for discharge. Sounds much better than shooting yourself in the foot for a medical discharge, doesn't it? There are two problems, however. First of all, if your commander doesn't believe you, you won't get the discharge. Secondly, you will get a "General Discharge" rather than the "Honorable Discharge" given to most soldiers, which is somewhat of a blot on your record.
Apply for a hardship discharge. If you can prove a specific family hardship such as a severely disabled relative who needs your care, you may be able to get an early discharge. You can also get out if you are the sole surviving son or daughter. If you had a parent or sibling who was killed, captured, severely disabled or missing in action during his military service and you are the only son or daughter left, you can apply for discharge.
Get a military education discharge. The Air Force and Navy sometimes allow personnel to leave the service early if they are accepted into an accredited medical program. You can usually get a discharge within 90 days of your separation date. If you are further from it than that, you may or may not be discharged.
Get kicked out. You can get kicked out for drug use, repeatedly failing basic military tests, committing serious criminal offenses and similar sorts of things. Invariably, this is a bad idea to try. Unless you commit a serious crime, your commanding officer will punish you, reassign you and/or try to rehabilitate you repeatedly, and you may never get out. If you do commit a crime, you will probably end up in military prison. Be smart and get caught making out with a like-minded soldier instead. Who knows, you might enjoy it!