This topic is complicated and confusing. It takes a lot of time to really learn it. And it needs a chapter in a grammar book to explain. I'll try a short version here.
Some verbs are followed by the gerund (-ing form of the verb) and other are followed by the infinitive and yet others can be followed by both. Modal verbs (can, may, should etc.) are followed by the base form of the verb.
Words similar to 'like', 'hate' 'prefer' take the infinitive or the gerund. However, 'enjoy' only takes
the gerund:
"I like running in the morning." /I like to run in the morning."
but only, "I enjoy running in the morning."
Use the infinitive after an object:
"He told me to study modal verbs first."
"She taught my daughter to play the piano."
"The principal asked us to wait until she was finished."
Verbs that give advise or suggestions mostly use the gerund.
(I have also given alternate way to use these verbs without the gerund.)
"I suggest drinking ginger tea to feel better."/ "I suggest (that) you drink ginger tea to feel better."
"I recommend drinking tea./"I recommend (that) you drink tea."
"My doctor forbids drinking tea."/"My doctor forbids me to drink tea."
"But she allows drinking coffee."/"But she allows me to drink coffee."
You can look up lists on the internet of which verbs take gerund or infinitive.
This is a HUGE topic, but I hope this gets you started understanding it. :)