Most visitors to the U.S. are required to apply for visas from their home countries, before arriving in the United States. If you haven't yet identified the type of visa you might qualify for, see Nonimmigrant (Temporary) Visas: Who Qualifies?.
You will have to locate the consulate nearest you that is authorized to issue the type of visa you want. The U.S. Department of State's Visa Resources can help you find the right one, and also provides other helpful immigration information.
Also check your local consulate's own website. You'll find helpful information about hours and application procedures. For example, some consulates require certain applications to be submitted only by mail, not in person.
You must usually do all or part of the visa application process in the country where you live. U.S. embassies and consulates outside your home country will normally refuse to accept your application—unless you can show a compelling reason why you are unable to apply at home. If, for example, the U.S. has no diplomatic relationship with the government of your homeland, another country's U.S. consulate might accept your application. Check with the embassy or consulate where you want to apply.
For some types of visas, such as visitor visas, applying involves simply filling out a few application forms and attending an interview at the embassy or consulate (though the final decision might be delayed while security checks on you are completed). At a minimum, you can expect to be asked to fill out State Department Form DS-160. You will need to complete it online and then arrive with a printout of the confirmation page.
For F-1 student visas, applying is a two-step process. First, you must find a school to admit you and send you a special form called an I-20. Then you take that form and your own application to the U.S. consulate.
For most work visas, applying is a three- or four-step process. First you must find a U.S. employer willing to sponsor you. Then, your employer must file paperwork with the U.S. Department of Labor (for H-1B and H-2B visas) and then with an office of U.S. Citizenship and Immigration Services (USCIS), requesting permission for you to apply for a visa.
After your employer gets USCIS approval, the next step is for you to file an application for a visa, most likely at the U.S. embassy or consulate in your home country.
In virtually all cases of applying for a visa, you will need to supply:
Even if you submit your application by mail, you will later probably have to go to the U.S. embassy or consulate for a personal interview. (For security reasons, the U.S. government requires personal interviews in most cases.) Contact the U.S. embassy or consulate in your country to learn its requirements.
Nothing happens as fast as it should in the world of visa applications. For example, while people were once able to get tourist and student visas in as little as a day, this is rarely true anymore. Many embassies and consulates have switched to requirements that you mail in your application and then come in for a personal interview later. And since the start of the COVID-19 pandemic, delays are a worse problem than ever, particularly when some consulates are closed to all but emergency cases.
Also, you will not be approved until your name has been checked against various criminal and security-related databases—which, if you have a common name, can add weeks or months to the process.
For more help on applying for a visa, consult U.S. Immigration Made Easy, by Ilona Bray (Nolo), or an experienced immigration attorney in your area.