Which one is correct, explain with reasons. 'He prefers to watch hollywood movies because they have good stories' or 'He prefers watching Hollywood movies because they have good stories'. Please also explain elaborately when to use gerund or infinitive after 'prefer'?
Your two example sentences are essentially equivalent, and can be used interchangeably. However the infinitive and gerund are not always interchangeable. One of the major differences is that only the gerund can be used as the object of a preposition.
For instance the following sentence is valid:
"Let's eat dinner before watching a movie." (valid)
But it is incorrect to use the infinitive in place of the gerund in that sentence:
"Let's eat dinner before to watch a movie." (invalid)
However, it would be valid to use the present tense in place of the gerund, so it would be fine to say:
"*Let's eat dinner before we watch a movie.*" (valid)
Regarding your question about the word "prefer" specifically, an example where the gerund would be ok but not the infinitive would be the following:
"I prefer swimming over dancing." (valid)
"I prefer to swim over to dance." (invalid)
Again, this is because only the gerund can be used as the object of the preposition "over".
According to Cambridge Dictionary, you are likely to encounter a to-infinitive after “prefer”.
He loathes Bollywood. He prefers to watch Hollywood movies. Their plots are so interesting.
However, you can’t make a comparison with a to-infinitive.
He prefers watching Hollywood to (watching) Bollywood.