A travel visa is a government document from a country that gives permission for an outside traveler to enter its borders. Almost verbatim from the Latin term "charta visa," which means "paper that has been seen", the visa for travel is essentially a pre-screening of a person and stamp of approval to travel in a country.
In practice a visa can be a separate document officially issued by a government or it can be an official stamp in one's official passport. For those who've traveled and never needed a visa, it's because the home country and target country already have a treaty in place allowing such travel in general. The United States and Canada for example have such an arrangement for their respective citizens.
The single-entry visa is a very limited traveler approval to enter a country. As its name infers, the single-entry visa can only be used for one trip. That means once the traveler has left the approval country, a new visa will be needed to enter again in the future. The old one is technically canceled as soon as the traveler leaves the target country.
On a legal level what makes a visa legal does not directly relate to its stated authorized period of visiting a country. If a single-entry visa says it is good for 90 days between Oct. 1 and Dec. 1, then the clock starts to tick when the traveler enters the country. So, for example, the traveler enters on Nov. 30, he has 90 days to stay. It does not mean he has to leave on December 1, a day later.
Further, when in country, the government can always change the terms of an existing single-entry visa, making it a longer period, a permanent visa for ongoing use, or shorten the time. The government ultimately controls the visa, not the traveler. Canceling of a single-entry visa can happen at any time, whether the traveler is in-country or not.
The most common offense with a single entry visa or other type is when a traveler stays too long in-country on an expired visa. It almost always gets caught at exiting or during an interaction with law enforcement and raises eyebrows immediately.
Penalties for staying too long are essentially treated the same as being in-country without permission. The usual treatment is a fine, but it can result in more serious response, such as being arrested and brought into to court. Many times a mark is put on the traveler's record to flag them on any future attempts to enter.
Not having a visa at all is even more serious. It signals that the traveler entered entirely illegally. Many cases result in deportation, but in more sensitive areas of the world the traveler can be subject to detention first or even be accused of spying.