In investing you own something and actually take delivery of it but when trading you do not own the asset you just go into an agreement with a other trader (through a broker) such that if the price of an asset changes you will settle the difference in price with the other trader.
An example of trading is if your view of the market is that Tesla stock price will rise and the other trader has an opposing view, you both can go into an agreement that whoever is wrong will settle the other party with the difference in price between when you entered & exited the agreement.
Trading is not gambling because before you enter the agreement as a trader, you are expected to have done some calculations/analysis which gamblers don't do.
Now when you invest you buy and hold something and there is a change of ownership in your name. You can hold the investment for as long as you like without any overnight fees or penalties because it is yours. When you invest you benefit from all the privileges' associated with the ownership of that asset.
For example when you invest in a stock it becomes your own and you are a shareholder of the company who can vote during company meetings but when you trade a stock you cannot vote during company meetings.