Silver coins can be earned by passing the normal levels, by playing the Daily Tasks, by completing the quests, and by completing event objectives.
Gold coins can be earned by completing event objectives, and by completing certain quests. Not all quests award gold coins, but for example the quests for reaching certain levels often have a gold coin award.
You can also buy both coins from the in-game shop. Gold coins can be bought with real money, whereas silver coins can be bought with gold coins. You can enter the shops by tapping the plus sign next to the coin balance indicator at the top right corner.