When there were only a few specialized goods, barter worked ok. As economies began to develop and more goods developed, barter did not work. Exchange amounts became too complicated or too cumbersome. Traders found that they had certain goods that were valued everywhere and that there was always a market for them. Those goods became a medium of exchange.
Money is anything that is generally acceptable in exchange for a good or service.
When money began, it was an item that a trader knew would be accepted by others. Money could be livestock, corn, salt, spices, gold, silver, etc. Money is a medium of exchange. That is what makes it different from other assets like stocks, bonds, land, or buildings. A medium of exchange is anything that is generally accepted as payment for goods and services.