To enter the United States legally as a foreign national, you must attain a valid visa (as a visitor, student, worker, fiancé, etc) and undergo customs inspection by border agents. Upon entering, you will be given a paper Arrival Card with some information about who you are, where you are coming from, where you will be staying, etc. (links to business mini-page and fiancé page, respectively)
When someone sneaks across the border, s/he commits what is known as Entering Without Inspection (EWI), which creates problems later on if that person wishes to leave through a border or remain in the country permanently.
A foreign national is unlawfully present is s/he comes to the United States EWI or overstays or otherwise violates a visa that permitted him/her to be in the country. When an alien accrues six months of unlawful presence, s/he is barred from the United States for three (3) years upon leaving. If an alien is unlawfully present for a year, s/he is subject to a ten-year bar from the country.
It is possible to waive or overcome these punishments, though doing so successfully is very difficult without the guidance of an experienced immigration lawyer. Learn more about the I-601 Waiver and Cancellation of Removal processes by visiting out pages on those topics.