There are already answers that explain border formalities, but I think the asker's confusion here stems from not really having understood what a visa is and what it's for, so let's take that.
Most fundamentally, a visa is something you apply for in advance. You go to the embassy/consulate of the country you want to visit, or you mail in all your documentation, and then they keep your passport for (up to) several weeks while their bureaucrats make a decision whether you should be allowed to go there, and eventually you get your passport back either with or without a colorful sticker (or, in earlier times, an ink stamp) that says you're permitted to go to such-and-such country in such-and-such period.
(You pay a fee when you apply for a visa, which you won't even get back if they refuse, the point being that it shouldn't be the taxpayers of the destination country who pay for the bureaucracy that processes the applications).
When you actually go there, there will be further questioning and stamping of your passport at the border when you you arrive, as the other answers explain -- how much depends on the country, but unless the country and yours are exceptionally chummy with each other, you would at least get a stamp in your passport saying that you passed through this-or-that border point on such-and-such day. You'll need that stamp later if you need to document to police or other authorities (such as the exit passport control when you leave) how long you've been there.
The purpose of the apply-in-advance must originally have been something about keeping spies and criminals out -- and they're still looking for that, but in practice the most important consideration is that if you come from a poor country and want to go with a rich one, the rich country wants to be really sure you're not going to move there, taking jobs from the locals -- or, worse yet, loafing around on their welfare system's expense. Unless you can prove beyond a reasonable doubt that that's not your thing, you won't get a visa.
Visa-free travel comes about when two (usually rich) countries come together and agree, "look, we're both pretty good places to live, so the risk that one of your guys is going to find it attractive to be an illegal immigrant with us (or vice versa) is pretty small. All that visa bureaucracy makes trade and tourism between our countries more difficult, let's just cut it out, okay?" So the two countries agree that holders of each others' passports don't need to get visas before they travel -- but usually they will still be questioned and stamped at the border.
In some countries, such as the UK, visa-free travelers will generally be met with more suspicion at the border because they haven't been pre-cleared (but it's still less hassle than applying for a visa for most travelers). In other places, such as the Schengen countries, all people from third nations in principle get the same screening at the border, and getting a visa is an additional hurdle to clear for citizens of less fortunate countries.
Poor countries don't generally have to fear a flood of economic migrants from rich countries, so when they require visas of travelers from the rich parts of the world, it is either a case of national paranoia or pride (both of which happen in the developed world too), or because country A demands visas of country B's citizens, and country B reasons that "if they make a hassle for our people, we'll make a hassle for theirs too".
Then there's something called visa-on-arrival. In this case one doesn't have to apply in advance, but can just arrive at the border to be questioned and stamped, like in the visa-free case. But you have to fork over money for a "visa fee" before you're let in -- effectively just a tax on arriving travelers from certain countries.
Typically this happens when country B above wants to have their cake and eat it too. They're not really interested in pre-screening country A's citizens, but they do want them to suffer in proportion to how their own citizens suffer when going to A, so they require a visa fee in the same ballpark as that charged by A's consulate. Or, of course, it may simply be a tax, levied because they can.