Trademarks (and service marks; that term will be explained later) are a term used to refer to an identifier for something placed in (legal) commerce. We have to make this additional point about it being legal, because you can't get a registration for something illegal. If, for example, you developed an improved version of crystal meth, that's bright blue because of its high quality, you won't be able to get a trademark registration on whatever name you put on it because the product isn't legal, or more likely, the cops will get your address from the trademark application and come bust you.
Trademarks are statutory in nature, meaning that in some cases you might have a perfectly valid and unique name but the law may prohibit you from registering the mark or claiming an exclusive right to an unregistered mark.
Trademarks and Servicemarks come in two flavors: registered marks and unregistered marks. In some jurisdictions, ownership of a mark comes from registration, if you don't register the mark and someone else does, they own it. (This is the situation with Internet domain names.) In some jurisdictions, the first party to use a mark owns it, and can take away ownership from someone who started using it later even though the other party had registered their use of the mark and the first user did not. (This is the status in the United States.) There are, of course, various exceptions to the rules, which is why we say that the wives of lawyers that handle this sort of law have mink coats. To add to the fun, a trademark/servicemark can be registered with the U.S. Patent and Trademark Office, or it can be registered with the Secretary of State or equivalent agency in each state where the goods or services are sold. Or it can be registered at both the state and federal level.
Generally, if a mark is not registered, the owner will try to warn people it claims some ownership by using TM next to the term. If a mark is registered with the Federal Government through the Patent and Trademark office, the owner can use the R-in-a-circle (R) symbol, or the much older "Reg. U.S. Pat. & TM Off." (Dupont likes to use the old format on its corporate logo). You can't use the (R) on a mark only registered at the state level, but you can mention the state registration. A lot of companies would register their marks with the Pennsylvania Department of Agriculture, which is why a lot of products would have a notice "Reg. Penna Dept. of Agr." on them. Some countries did not allow the use of the R in a circle notice so some countries where a product's mark is registered the product would have the notice "Trade Mark Regd." on it.
There are certain marks you cannot register. A mark consisting of the coat of arms of seal of a country generally isn't registrable. Also, a government may grant trademark status for certain terms used by its organizations, these are called "Chartered Marks" because the ownership of the mark was granted by charter. The Boy Scouts, the 4H Club (and its special 4 leaf clover), the FDIC, and certain other organizations, have been granted ownership of their name or mark by statute. Also, the state flag and state seal of each of the 50 states is not registrable by a private organization.
Then there are marks of international organizations that can't be used without their permission. The word "Olympic" or the 5 interlocking rings; the UN flag or logo; the Red Cross (Johnson & Johnson can still use the Red Cross for cotton in the United States because they were using it more than 100 years ago before the symbol was protected), Red Crescent or Red Crystal.
So anyway, a trademark is an identifier. That identifier can be a word or two (Perrier water, Total gasoline, Microsoft software, Jiffy Lube oil changes), a phrase (The Sweetheart of the Corn is a trademark that still appears on boxes of Kellogg's Corn Flakes, and Canadian Club Whiskey is also known by the phrase The Best in the House), an image (the Bat symbol (not to be confused with another bat symbol) appearing on a bottle of Bacardi Rum), a sound (The MGM Lion's roar for motion pictures), or even a color (as defined by something like a Pantone number; Owens Corning, for example, won the right to trademark a very specific shade of the color pink for use in fiberglass insulation, and MGM still holds the trademark on the exact green used for the Wicked Witch of the West in The Wizard of Oz).
Trademarks are proper names; that's why they are capitalized when used to refer to the particular product or service. A trademark is classed as "strong" or "weak." A strong mark is so significant that any use typically implies the original company, e.g. if you sold silverware with the name "Exxon", that company would very likely be able to successfully argue in court that anything with that name would be thought to come from the oil company. However, if you sold something under the name "Acme", that mark is so weak that even Warner Brothers probably couldn't stop you.
Trademarks encompass two types of identifiers; a "trademark" is an identifier applied to some physical thing (a "good"). A "service mark" (or "servicemark") is an identifier applied to some practice (a "service") that is made available to the public but doesn't actually provide some physical thing. For example, your house has electricity for power and may have natural gas or oil for heating. The brand the electric company uses is a service mark because you don't have any actual goods (you can't store electricity). However, the brand of oil or gas is a product you do receive, a physical good (which you could store), and is a trade mark. Now, if you are supplied utilities by a company that provides both gas and electric (the Pacific Gas & Electric Company of San Francisco) then their name can be both a trademark and a service mark.
In the examples given earlier, the color pink used on insulation is a trademark (you actually have the insulation), but Jiffy Lube is a service mark, you had the service of an oil change done (and the oil change is done using oil bearing the "Pennzoil" trademark). As noted earlier, in some cases the identifier can be both a trademark and a servicemark. While the MGM Lion Roar sound was a service mark until the 1980s since you didn't get a copy of the film, you just got the service of viewing the film, but now you can get the service of watching a film in a theatre, and the goods of the actual film on video disc, this sound mark could be both a trademark and a service mark.
A trademark or servicemark is used to identify goods or services that you produce; you do not necessarily have to be a commercial organization or even making a profit to obtain one to identify your products and services. For example, a religious organization might have a trademark on the name of its particular religious text ("The Most High Sun Prayer Guide") and a service mark for the name of its particular religion. ("PraySun"). The Salvation Army has a service mark registration on its red shield, and the Jehovah's Witnesses have trademarks in their publications "Awake!" and "The Watchtower".
There's also a third class of trademark/service mark where the mark's owner licenses use of the mark to third parties. For a commercial business, it's called franchising. McDonald's, Burger King, Wendy's, etc. own their own restaurants and also franchise use of their trademarks and service marks to others. However, when you do not use the mark yourself but allow third parties to use it to certify that the goods or services they sell meet certain quality requirements, then it's a "certification mark". The UL label on products indicates that the manufacturer submitted its device to Underwriters Laboratories Inc. for destructive testing; if the device survives over what would be extreme use by consumers, the manufacturer gets permission to put the UL certification mark on its product.
A trademark or service mark can be valuable for those who sell products directly (e.g., Ore-Ida as a brand of french fries) or who sell through franchisees who purchase the permission to use that trademark (e.g., McDonald's as a brand of french fries).
Trademarks, along with Copyright and patent, are considered "intellectual property" in that it's a special type of government-granted monopoly. Trademarks, however are different from copyright; A copyright owner can ignore some infringing uses of its works and does not lose the ability to go after other infringements. But if you own a trademark and do not make efforts to stop unauthorized uses of your mark of which you are aware, someone doing exactly that can use your failure to "police" your mark to prevent you from stopping him from using it as well. Also, if a trademark does not represent a distinct, specific owner to people who use the product or service it identifies (as opposed to the trademark or service mark being the "generic" term used to describe the product), the trademark can be declared "generic" by a court and then anyone can use it. This is why anyone can call acetylsalicylic acid "aspirin" in the United States, it's become the generic term for that product. (Aspirin is still a trademark of Bayer in the United Kingdom, however.)
Then there is the concept of Fair Use, (which while normally relevant to copyright, also applies to use of other people's trademarks), where someone can use someone else's trademark whether its owner likes it or not. For example, let's say I run a blog and I post openly that I happen to hate Coca-Cola because I think it tastes bad, and I happen to like Dr. Pepper. They can't successfully sue me because it's a legitimate commentary. (To be fair, I will note that my brother, on the other hand, likes Coke and hates Dr. Pepper.) This use of their trademarks is fair use because I am giving a comparison of products. Now, if I sold a soft drink called "Swill", and I ran a survey, I could legally say that "86% of customers preferred Swill over Mountain. Dew" (as long as it was true). (This was the entire premise of the Pepsi Challenge, where Pepsi showed that people preferred it over Coke, and started the Cola Wars of the 1980s.)
When a mark becomes generic, anyone can use it, and it is no longer capitalized except when used as the first word of a sentence. Note that a mark can be generic in one use and a strong trademark or service mark in another. It's perfectly legal to sell solid fuel under the name "coke" (a type of processed coal) without getting permission from anyone, but unless you're selling "The Real Thing" you'd better not try to sell any beverage under the name "Coke" unless it's authorized by the Coca-Cola Company of Atlanta. The word "peanuts" (not capitalized) refers to nuts that grow underground, but the word "Peanuts" (capitalized) refers to a comic strip by Charles Schulz as well as a series of books and TV specials.
The strongest identifiers which can be used as trademarks or service marks are coined words that have no other meaning (Exxon) and use on unrelated products could be stopped, while marks that have been used for a lot of different things may be so weak (Acme) that only a competing use on the exact same product as sold by a third party can be stopped by a trademark owner. And some marks cannot be made trademarks because they are the only way to use that particular term. A company named Blish Manufacturing tried in the 1940s to register as a trademark the word "Copyright" as a brand of flour. The Patent and Trademark Office turned them down because there would be no way for any competing flour manufacturer to put a copyright notice on its product without infringing on Blish's trademark.