A demat account is like a bank account for your shares and stocks in which the shares/stocks are held in an electronic format. Demat accounts make it much easier to own and trade stocks, shares, mutual funds, ETFs by eliminating the hassles of lengthy paperwork. Demats have streamlined the process of owning and holding shares.
Note that a demat account and trading account are not the same. A demat account is usually accompanied by a trading account, which is required for purchasing and selling stocks in the share market. So, a trading account is used to buy and sell shares while a demat account is used to hold them. Similar to a bank account, where money is debited and credited, shares are debited and credited from a Demat account.