A stock exchange is an institution, organization or association that serves as a market for trading financial instruments such as stocks, bonds and their related derivatives. Most modern stock exchanges, like NYSE Euronext, have both a trading floor and an electronic trading system.
Increasingly, exchange owners and operators are getting themselves listed on their own exchanges and have become private companies just like any other company. This is the case with companies like NYSE Euronext, Deutsche Boerse AG and the NASDAQ OMX Group. These companies have evolved into international groups operating on different continents and gathering multiple activities like traditional stock markets, derivatives markets and commodities markets.
Stock exchanges have a vital function in modern economies as places where investors and companies can meet and exchange capitals. They offer standardized instruments which are traded with transparency contrary to what happens in OTC transactions. They display prices and volumes for every products they trade.
In the 80's and 90's with the development of computer technologies, stock exchanges have been dematerialized and most of the transactions now happen electronically though some exchanges have kept floor trading activities like the NYSE. Euronext has adopted a fully electronic system.
Traditional stock exchanges have met increasing competition from fully electronic platforms. Electronic trading has reduced the cost of entry into the market and several new exchanges have recently developed.
The first stock exchanges date back to the Middle Age in Europe with debt trading between merchants. However the first stock trading can be found in the 17th century with the creation of various companies to explore European colonies such as the Dutch East India Company. Historically stocks and bonds were traded in a physical place or building with traders gathering on the floor and exchanging financial titles by hand.
14c Stocks were instruments of punishment.  The original Stock Market was a fish and meat market in the City of London on or near the later site of Mansion House, so called perhaps because it occupied the site of a former stocks. 1809 Place where securities are bought and sold. Stock + market. 
12c Markets were a place to meet at a fixed time for buying and selling livestock and provisions, to trade, deal in, buy, wares, merchandise, public building or space where markets are held" first attested mid-13c. Sense of "sales, as controlled by supply and demand" is from 1680s, market research is from 1926. 
See also List of Stock Exchanges